Cell Reference in a Macro

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

I am looping through a macro, testing the contents a data
in column A. If I find a "P" in the first position clomun
A, I want to capture the value, if there is one, in column
C and column D in that row. I want to keep a running
balance of the sum of those values by column.

I am not sure how to reference those cells when I find
a "P" in column A.

Range("A1").Select
For I = 1 to 100
If Left((ActiveCell,1)="P" Then
TotalC = TotalC + ???
TotalD = TotalD + ???

How do I reference the cells in C and D to add the values
to the running totals?

Something like ActiveCell.Offset(0,2).Value?

TIA.
 
Range("A1").Select
For I = 1 to 100
With ActiveCell
If Left((.Value,1)="P" Then
TotalC = TotalC + .Offset(0,2).Value
TotalD = TotalD + .Offset(0,3).Value
....
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top