Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cell Address in VBA

89 views
Skip to first unread message

Robert

unread,
Feb 7, 2002, 8:00:34 AM2/7/02
to
How can I test if a specific cell (row 65 or row 66) is
active in Excel 97 VBA using the Worksheet Change Event?

i.e.;
Dim myCell As Object 'String

With Worksheets("Sheet2").Range("A65:M68")
myCell = Cells.Address()

End With
If myCell = R65C8 Then 'Change in GPM % - line 1
' Calc MU percent
Range("G65").Value = Range("F65") / ((100 - Range
("H65")) / 100) * (100 / Range("F65")) - 100
'Calc case price before local tax
Range("J65").Value = Range("F65") + (Range("F65") * Range
("G65") / 100)
ElseIf myCell = R66C8 Then 'Change in GPM % - line 2
'MsgBox "The selection is " & Selection
' Calc MU percent
Range("G66").Value = Range("F66") / ((100 - Range
("H66")) / 100) * (100 / Range("F66")) - 100
'Calc case price before local tax
Range("J66").Value = Range("F66") + (Range("F66") * Range
("G66") / 100)
End If

Tom Ogilvy

unread,
Feb 7, 2002, 8:38:37 AM2/7/02
to
The change event will tell you the cell you are leaving. The
selectionchange tells you which cell is entered. If you are validating data
entered you can use change - the Target argument tells you the cell that
triggered the event - so you can just test for the address of target

if Target.Address = "$A$66 or Target.Address = "$A$65" then

or

if Target.Row = 65 or Target.Row = 66 Then

Regards,
Tom Ogilvy

"Robert" <roa...@home.com> wrote in message
news:113c01c1afd7$6e4f3a40$9ae62ecf@tkmsftngxa02...

0 new messages