View Single Post
 
Old 01-09-2024, 08:16 PM
soroush.kalantari soroush.kalantari is offline Windows 10 Office 2021
Competent Performer
 
Join Date: Jun 2021
Posts: 124
soroush.kalantari is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
I'm not sure on the purpose of this macro but your loop might work with
Code:
  For i = 2 To 100
    Range(Range("range" & i), rng0).Select
    Set rng0 = Selection
  Next i
Thank you for your reply. The purpose of this code is to select some nonadjacent defined names which has be named range1, range2 and so on plus a user selected range. (see the attached picture, in which if active cell be A5 and defined names ranges be the colored ranges, the macro is expected to select the colored ranges and A5.)
Your code don’t work like this. (it selects also the cells between defined names, for example A9)
Attached Images
File Type: png selectnonadjacent01.PNG (17.7 KB, 9 views)
Reply With Quote