name ranges in array

  • Thread starter Thread starter igorek
  • Start date Start date
I

igorek

Hi Folks,

Can anyone help with the array feed please?

I have numerous name ranges in the file and i want to feed an array with it.
Let say i have K number of ranges. How do i feed Ranges() array with it?

Thanks
Igor
 
I'm not sure what you're doing, but Union sounds like it might be what you're
looking for.

Dim K as long
dim rCtr as long
dim myRngs() as range
dim OneRng as range

k = 3
redim myRngs(1 to K)

with worksheets("Sheet9999")
set myrngs(1) = .range("A1")
set myrngs(2) = .range("w1:z1")
set myrngs(3) = .range("L9")
end with

set onerng = myrngs(lbound(myrngs))
for rctr = lbound(myrngs) + 1 to ubound(myrngs)
set onerng = union(onerng, myrngs(rctr))
next rctr

msgbox onerng.address
 
Dave,
this is not exactly what i'm trying to do. the name ranges that i'm
referring to (Ctrl+F3) need to be fed into an array. And i do not know how to
do that. can you please let me know how to do it via look that goes through
ActiveWorkbook.Names

thanks
Igor
 
Option Explicit
Sub Text()
Dim allnames() As String
Dim nm As Name
Dim index As Long

ReDim allnames(1 To ThisWorkbook.Names.Count)

For Each nm In ThisWorkbook.Names
index = index + 1
allnames(index) = nm.Name
Next

MsgBox index & " names in the array"

End Sub
 
Back
Top