#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default named cells

Is there a way to save and refer to a cell with a one name variable?
Instead of range something or cells(1,2) or "A1" can you just call it,
like, "ThatCell". Like... ThatCell = Cells(1,2) and then ThatCell means
Cell(1,2) not the value that is in cell(1,2).


I am doing a trial and error solution and have to save the cells I've
tried... not their value. I am hoping to save them in an array. I know I
can save them in an array Saved(x,y) with the colum,row coordinates...
it's just kind of a pain.

I'd like to end up with trial(1) trial(2) etc .

thanks

John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default named cells

just set it to a range, but i'm not sure what you mean by "save". save for how
long?
couple examples:

Sub test()
Dim ThatCell As Range
Set ThatCell = Worksheets("Sheet1").Range("A1")
ThatCell = 1
End Sub


Sub test2()
Dim i As Long
Dim ThatCell(5) As Range
For i = 1 To 5
Set ThatCell(i) = Worksheets("sheet1").Cells(i, 1)
ThatCell(i) = i + 1
Next
End Sub

--


Gary


"John" wrote in message
...
Is there a way to save and refer to a cell with a one name variable? Instead
of range something or cells(1,2) or "A1" can you just call it, like,
"ThatCell". Like... ThatCell = Cells(1,2) and then ThatCell means Cell(1,2)
not the value that is in cell(1,2).


I am doing a trial and error solution and have to save the cells I've tried...
not their value. I am hoping to save them in an array. I know I can save them
in an array Saved(x,y) with the colum,row coordinates... it's just kind of a
pain.

I'd like to end up with trial(1) trial(2) etc .

thanks

John



  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default named cells

Dim ThatCell As Range
Set ThatCell = Cells(1, 2)

Of course, ThatCell does not have to refer to only one cell (it can be
multiple areas/cells - it just cannot span different worksheets). You can
add cells to it by

Set ThatCell = Union(ThatCell, Cells(1, 3))

and check if a cell is a part of ThatCell range by

If Intersect(ThatCell, Cells(1, 4)) Is Nothing Then
'Not part of the range
Else
'Included in ThatCell range
End If



"John" wrote:

Is there a way to save and refer to a cell with a one name variable?
Instead of range something or cells(1,2) or "A1" can you just call it,
like, "ThatCell". Like... ThatCell = Cells(1,2) and then ThatCell means
Cell(1,2) not the value that is in cell(1,2).


I am doing a trial and error solution and have to save the cells I've
tried... not their value. I am hoping to save them in an array. I know I
can save them in an array Saved(x,y) with the colum,row coordinates...
it's just kind of a pain.

I'd like to end up with trial(1) trial(2) etc .

thanks

John


Reply
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
How many named cells greg Excel Programming 4 January 30th 07 08:57 AM
Excell named cells or labeled cells question [email protected] Excel Programming 8 June 25th 06 05:15 PM
Excel named cells or labeled cells question [email protected] Excel Programming 2 June 25th 06 04:39 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Reffering to named cells Zulupiper Excel Programming 2 May 4th 06 12:42 PM


All times are GMT +1. The time now is 05:21 AM.

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

About Us

"It's about Microsoft Excel"