ndendrinos
Well-known Member
- Joined
- Jan 17, 2003
- Messages
- 1,694
Named range “toplist” is contiguous [A1:L1]
Named range ‘mylist” is non contiguous
(“A24,B23,A16,D20,E12,F27,E16,A15,K14,L20,P21,M19")
On sheet1
I’m looking for code that looks something like this:
My understanding is that because one range is non contiguous there needs to be a loop
and I need assistance
something like this
Named range ‘mylist” is non contiguous
(“A24,B23,A16,D20,E12,F27,E16,A15,K14,L20,P21,M19")
On sheet1
I’m looking for code that looks something like this:
Code:
[mylist].Value = [toplist].Value
My understanding is that because one range is non contiguous there needs to be a loop
and I need assistance
something like this
Code:
Sub test()
Dim rngCell As Range
Dim lngCount As Long
Dim aTemp()
ReDim aTemp(0)
lngCount = 0
For Each rngCell In [toplist]
aTemp(UBound(aTemp)) = rngCell
ReDim Preserve aTemp(UBound(aTemp) + 1)
Next rngCell
ReDim Preserve aTemp(UBound(aTemp) - 1)
With Worksheets("sheet1")
For Each rngCell In [mylist]
rngCell = aTemp(lngCount)
lngCount = lngCount + 1
Next rngCell
End With
End Sub
Last edited: