access a cell in a range

  • Thread starter Thread starter keyser_Soze
  • Start date Start date
K

keyser_Soze

I have variables:

dim myrange as Range
dim myString as String

myrange specifies a specific column. How can I specify the cell in row
1 of myRange so I can set it's contents to myString?
 
Hi there keyser soze,

(Fan of the movie, eh? ;) <g> )

Like so ..

myString = myRange(1).Value

HTH
 
yes, I liked the movie.

Shouldn't that be
myRange(1).value = myString

?

Thanks again
 
Not if you want to set the contents of your variable to the cell value, as
you stated.
 
I'm sorry, I thought I replied to this, not sure what happened..

If you're looking to set your variable value from this, then no, you don't
want to do it that way. It would be ...

myString = myRange(1, lngColumn).Value

Where lngColumn is a variable (either input by hand or used as an actual
variable) which specifies your desired column. If you are wanting to set
the desired cell as a range variable and not as a string varible, it would
look like this ...

Set myRange = Cells(1, lngColumn)

Same principal applies to the lngColumn. Substitute a column number if
you'd like, or use a variable.
 
Back
Top