Thread: VBA syntax
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default VBA syntax

Right click the sheet tab View code and paste the below code

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox Target.Address & vbCrLf & Target.Row
End Sub

The worksheet change event will be fired as soon as you change a field
value.. Target refers to the cell you are in. Target.Row refers to the row
and similarly column..Target.Value refers to the value you have typed in

If this post helps click Yes
---------------
Jacob Skaria


"Derrick" wrote:

hi again. thanks for the explanation! now im wondering if i can:
not use the active cell.. but the cell i've just edited...
because if i press enter, it gives me the active cell row below the cell i
just edited
if i press tab im still ok. but i dont wanna have that possibility
is this achievable?

"Jacob Skaria" wrote:

Activecell
refers to the current cell in VBA.

ActiveCell.Address
returns the current cell address

ActiveCell.Row
returns the current row and similarly column..

If this post helps click Yes
---------------
Jacob Skaria


"Derrick" wrote:

thanks Jacob
im not quite sure what it all means.. can you explain what is happening with
msgbox, and the other .Column, .Address lines?
.. so i can know how to edit it later


"Jacob Skaria" wrote:

Msgbox Activecell.Row
Activecell.Column
Activecell.Address

If this post helps click Yes
---------------
Jacob Skaria


"Derrick" wrote:

how do i select the current cell im in .. in vba
lets say, im in B3 and edit the value - im working on a code that will say:
- in Row 3, check and recalculate D3 if necessary(which uses VBA to create a
validated list based on a loop... so i can't just use formulas)
if in row 4, check and recalculate D4.

so.. i need to be able to get the number of the row im in.. so i can set it
to a variable and go from there

any help?