groovygarden
Programmer
- Aug 23, 2001
- 63
Hi
I haven't used VBA much, but have managed to muddle together a small macro. However, I'm stuck on one thing and I'm not having much luck googling it, as not really sure what words to search for...
My macro starts:
Now, I need to create a new variable, SiteName, which will refer to a cell on my worksheet. The row of SiteName must be the same as Target, whilst the column will always be A. EG: if Target is E4, then SiteName must be A4, if Target is G6, then SiteName must be A6 and so on.
How do I declare and set the cell address of SiteName?
If I then need to use the value of the cell SiteName refers to, can I just do something like:
?
Many thanks
PS: I've tried various versions of this:
I haven't used VBA much, but have managed to muddle together a small macro. However, I'm stuck on one thing and I'm not having much luck googling it, as not really sure what words to search for...
My macro starts:
Code:
Private Sub Worksheet_Change(ByVal Target As range)
Now, I need to create a new variable, SiteName, which will refer to a cell on my worksheet. The row of SiteName must be the same as Target, whilst the column will always be A. EG: if Target is E4, then SiteName must be A4, if Target is G6, then SiteName must be A6 and so on.
How do I declare and set the cell address of SiteName?
If I then need to use the value of the cell SiteName refers to, can I just do something like:
Code:
IF SiteName = "Building" THEN...
?
Many thanks
PS: I've tried various versions of this:
Code:
Dim SiteName As Range
Range(SiteName).Row = Range(Target).Row