Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Question - Referencing a cell in another worksheet with variabl

Status
Not open for further replies.

KBFINN

Programmer
Nov 18, 2002
9
US
Can anyone help with the syntax of this statement:


If Worksheets("Columns to Verify").Range("&CellToCk") = "X" Then

The following statement works fine:

If Worksheets("Columns to Verify").Range("G2") = "X" Then

How do I format the statement where I determine the value of CellToCk ?

I have tried all the combinations of Quotes (") and concatentation (&) that I can think of.

Thanks in advance for your help.

 
Depends if cellToCk is defined as range or string. I'm guessing it's defined as string as you are specifying the worksheet:

If Worksheets("Columns to Verify").Range(CellToCk) = "X" Then Rgds
~Geoff~
 
Range argument is a string. So something like :-

Dim CellToCk As String
CellToCk = "G2"
If Worksheets("Columns to Verify").Range(CellToCk).Value = "X" Then
Regards
BrianB
** Let us know if you get something that works !
================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top