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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel Select Cells in R1C1 type method

Status
Not open for further replies.

dprayner

Programmer
Oct 14, 2002
140
US
Hi People.

I was wondering why the following code is erroring out:

For I = 2 To 8
For J = 3 To LastRowColA
If PBNum = Sheet1.Range(Cells(I, J), Cells(I, J)) Then 'ERROR LINE
Counter = Counter + 1
End If
Next J
Next I

I am trying to reference a single cell at a time which works when I put in the numbers Sheet1.Range(Cells(1,2), Cells(1,2)), I need to change columns and rows hence the need of a couple of For loops.

The command doesn't seem to want to accept column or row #s as arguments.

Any suggestions?

Thanks in advance, DAVE
 
And what about this ?
If PBNum = Sheet1.Cells(I, J) Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 




Hi,

The syntax is Cells(rownum, colnum)

Do you have your rows & columns (I & J) switched? If LastRowColA exceeds 256 (the max number of columns), you will get an error.

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top