I need to select multiple ranges.
This is my code to select the first range, but now I need to edit this line to add the second range.
Range(ActiveCell.Offset(-1, -8), ActiveCell.Offset(-1, -2)).Select
Range("A:G,T:W") is what I'm trying to grab dynamically.
Update: VincentG gave me code
Intersect(ActiveCell.EntireRow, Range("A:G,T:W")).Copy
I've copied the range, but now I need to paste it in the row below, same columns. I tried to use the same code
Intersect(ActiveCell.EntireRow, Range("A:G,T:W")).PasteSpecial (xlPasteValues)
to paste but it gives me the error
"This action won't work on multiple selections"
Your code is syntactically correct, but I suspect you aren't getting the expected result. Further guessing: I guess you want to select A:G and T:W on the current row. If that guess is correct, then try this:
Union( _
Range(Cells(ActiveCell.Row, "A"), Cells(ActiveCell.Row, "G")), _
Range(Cells(ActiveCell.Row, "T"), Cells(ActiveCell.Row, "W")) _
).Select
For anyone else looking at this post:
I ended up copying the one section, pasting it where I needed it, then using activecell.offset, I chose the other range, copied and pasted. I never did find a way to copy and paste multiple ranges.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.