I was hoping someone may direct me in my search for a solution to a pretty simple problem. In my code I would like to (1) use a loop to build a string of rows that need to be hidden (figured this part), and then (2) use the string I've built to hide all the rows using Range().EntireRow.Hidden = True.
The line of the code that returns an error is as follows (rowsToHide is a variable that I use in the loop to built a string of rows that need to be hidden):
The code works fine if the rowsToHide variable consists of a relatively small numbers of cells (e.g., if rowsToHide = "A1,A3,A8" the code would work just fine and will hide rows 1, 3 and 8). However, if the value of rowsToHide becomes something like "A2,A5,A6,A7,A9,A12,A13,A14,A16,A19,A20,A21,A23,A25,A28,A29,A30,A32, ...." (and so on and so forth) the code will return an error instead of hiding rows 2 5, 6, 7 etc..
From what I can tell this is because the .Range() object is limited to 255 symbols. I was wondering if there's a workaround for this problem? Maybe, a different approach? I would very much like to build a string first and then hide all the rows as hiding them one by one would be very slow.