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

Excel - On Cell Change Event

Status
Not open for further replies.

James1981

Programmer
Nov 2, 2002
76
0
0
US
Hi,

Is there an event in VBA that is triggered when a user changes the value in a cell - i.e. when the user hits enter.

Cheers

James
 
yup...

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
end sub

you can put that in the worksheet that you want to have the change event in....the target is the cell that was changed.
hope this helps
 
Private Sub Worksheet_Change(ByVal Target as Range)
Target.Font.ColorIndex = 5
End Sub

Occurs when cells on the worksheet are changed by the user or by an external link.

Syntax

Private Sub Worksheet_Change(ByVal Target As Range)

Target The changed range. Can be more than one cell.

Remarks

This event doesn't occur when cells change during a recalculation. Use the Calculate event to trap a sheet recalculation.

Deleting cells doesn't trigger this event.
------------------------------------------------------------
This example runs when any worksheet is changed.

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)
' runs when a sheet is changed
End Sub

Occurs when cells in any worksheet are changed by the user or by an external link.

Syntax

Private Sub object_SheetChange(ByVal Sh As Object, ByVal Source As Range)

object Application or Workbook. For more information about using events with the Application object, see Using Events with the Application Object.

Sh A Worksheet object that represents the sheet.

Source The changed range.

Remarks

This event doesn't occur on chart sheets.

This was in help files.
Dave.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top