View Single Post
 
Old 01-09-2024, 03:14 AM
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 How to select nonadjacent difiened names at once?

I have written following code to select some nonadjacent difined names plus a user selected range at once (see the Excel attachment. It give error at “Range("""" & Range("range" & i).Address(0, 0) & "," & rng0.Address(0, 0) & """").Select” line. Can you give me some guides on this issue?

Sub selectnonadjacentdinfinedname()
Dim i As Integer
Dim rng As Range
Dim rng0 As Range
Set rng = Selection
Set rng0 = Range("range1")
For i = 2 To 100
Range("""" & Range("range" & i).Address(0, 0) & "," & rng0.Address(0, 0) & """").Select
Set rng0 = Selection
Next i
Range(rng, rng0).Select
End Sub
Attached Files
File Type: xlsm selectnonadjacent.xlsm (17.8 KB, 4 views)
Reply With Quote