I need to select ranges concatenating Addresses in VBA

Asked

Viewed 129 times

0

I have a sub in VBA that does several calculations to get into a range address list listaAddresses = "$A$1, $H$3,$V$1,$M$16,$A$21,$B$13,$H$88..... $T$44"

With this list I need to select all ranges. So I tried - Range(listAddresses). Select

However, when I have more than a certain number of Ranges, VBA and VB (tried in both), give error and do not select any cells.

  • Hello colleague. I could not reproduce the problem you say you have. In a quick test set the variable listaAddresses = "$A$1,$H$3,$V$1,$M$16,$A$21,$B$13,$H$88,$T$44" and then called the selection making Range(listaAddresses).Select. It worked, as you can see in this screenshot: http://imgur.com/a/CYWmw Edit the question to explain better or make a [mcve] that reproduces the problem.

  • I just got it. I looped the Addresses lists and used Union to concatenate all the Addresses

  • The problem happens after 255 separate ranges. I think it must be some string limit.

  • Well, okay. Maybe there’s some limit even on the number of intervals you can pass to the method Select (despite of documentation do not specify anything). You should have made it clear that this was the problem in the question. I suggest editing the question to put this information (that an error occurs - by the way, indicate which error occurred - when there are more than 255 separate intervals). Then I also suggest that you create an answer with your solution (the idea of Union is very good! ). If you do this, you get my +1 question and answer. :)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.