LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Problem trying to us a range variable as an array variable

Try:

Set HeadersRng(a) = ActiveCell



"TBA" wrote in message
...
But I want a range, and changing it to HeadersRng(a) = ActiveCell doesn't
work either.

-gk-


"shockley" wrote in message
...
ActiveCell.Address returns a string, not a range, which is why you get

the
error. Dim your variable as String.

HTH,
Shockley



"TBA" wrote in message
...
Below is a bit of code I use to store header values into a

one-dimensional
array, along with the some less important information like the column

width
of the column each header is in (it's important to have this, trust me
heh). All variables have been declared.

TblWidth = 0

For Each Cell In Range("Database").Rows(1).Cells
TblWidth = TblWidth + 1
Headers(TblWidth) = Cell.Value
HeaderWidths(TblWidth) = Cell.ColumnWidth
Next Cell

What I'd also like to do is create a one-dimensional Range array

variable,
say HeadersRng(a), that will store the location of each header as a

range.
I've tried this:

Dim HeadersRng(100) as Range
Range("Database").Rows(1).Columns(1).Select

For a = 1 To TblWidth
HeadersRng(a) = ActiveCell.Address
ActiveCell.Offset(0, 1).Select
Next a

I'm getting a Run-time error '91': Object variable or With block

variable
not set.

I realize there may be a better way to loop through this process,

perhaps
even in the first loop I referenced. However, I feel that I am

missing
something fundamental here. Am I close? Any and all help

appreciated.
Thanks!

-gk-

PS this group rocks! thanks so much for all the help I've received

so
far.











 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
Finding max array value of variable cell range The Fisherman Excel Discussion (Misc queries) 0 February 6th 07 02:54 PM
Variable range addresses for use in array functions NickCory Excel Discussion (Misc queries) 3 September 11th 06 11:00 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


All times are GMT +1. The time now is 08:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"