Jump to content
Macro Express Forums

Recommended Posts

There are lots of times when I wish MEP would allow more than one dimension for a variable array. A simple example would be when I'm trying to store the contents of a spreadsheet. I could use one dimension for the row, and the other for the column. That way I could refer to an array element as, say, T[5,4]. As far as I know, this is not possible.

 

Does anyone have a way to deal with this limitation? I've thought about using an array where the elements are other arrays, but I haven't figured out how to make that work. A 2-dimensional array would be so much easier.

 

Any ideas?

 

Rich

Link to comment
Share on other sites

Yes, that would allow me to address any particular cell, but it requires me to declare an array variable for every possible column - a royal pain. And how would you write a loop structure to step through all cells in a (2-dimensional) range? You'd have to have a separate loop for every column (A, B, C...).

 

Rich

Link to comment
Share on other sites

Not having multidimensional arrays is a pain. I'm just giving you the best suggestions given the limitations. Personally it's another reason I prefer .NET because it has DataTables.

 

But you don't have to loop though every column. Simply use an increment integer as a pointer. IE for %pointer% = 1 to 1000. %B[%pointer%]%. For rows you could name the column numbers, EG A = 1, or I imagine you could do the math to get the ASCII value and add it to an incrementing integer. "A" is 65 so make it 65 + %pointer%. You might have to run as command text however. I know. It's sloppy. Or save all the value in a single array and do the modular math. Or perhaps create your own addressing system in a second array where the one would contain the row/column and search it each time and use the pointer from it to use as a pointer in the other array.

 

No solution I can think of is elegant. You can see why programming languages evolved to have tabular data structures.

 

In .NET it's simple to reach in and grab and modify cells using Interop. In fact it can do anything a person can do. I was considering writing a simple command line program that would take a few parameters and do some of the normal operations MEP users would want. It woud be really simple. Tell it the file name, worksheet name, and range and it would return the values for instance. And it all could be run like an external command so it would be invisible. Click here and you can see all the things we could do with Interop. But until I find some way to be compensated I need to work on my other programs that clients pay me for. I've been wanting to write some add-ons for Excel for some time so if you or anyone are interested, maybe we could even do some crowdfunding, I'd love to create something like this. The other one I would love to write is a RegEx add on. I've posted here before suggesting it but received no responses.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...