Hi All,
I have tried hard to figure this out, but to no avail. All I want to do is select multiple rows (or multiple anything for that matter) in VBA, mimicking when you use CTRL-Click in Excel. I have tried two approchaes:
Approach 1: Use some sort of "add to selection" method in VBA. Does such a thing exist? The Macro Recorder just includes all the selected rows into a single range.
Approach 2: Toggle the "Add to Selection" Mode, make the selections, then toggle again. SHIFT-F8 does this in Excel, so I tried to use SendKeys to do it:
SendKeys "+{F8}"
Sendkeys doesn't quite work like I thought it did, first doing nothing when I step through the code, then when I run the code, it puts the keystrokes into the code iteself! (Example: SendKeys "Hello" puts "Hello" in the code wherever the cursor was)
While I'm at it, I'll explain the context as well. I need to delete all rows except the Nth rows of a worksheet which was created by a numerical simulation. The method below works, but takes a while. I figured that selecting all the "dead" rows first and then deleting them with one delete command would be faster (I already have disabled screen updating and automatic calcs.)
Any help to make this one work better, or a better "delete all except Nth Row" technique would be appreciated.
Thanks!
-Alex
Bookmarks