S
Steve
I found this post by Dave Peterson in 2007. I want to set some conditional
number formatting similar to how this code works but want to execute the code
for columns d through o. I tried changing Me.Range("a:a") with
Me.Range("d") and got a compile error: "invalid use of me keyword".
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRng As Range
Dim myCell As Range
Set myRng = Intersect(Target, Me.Range("a:a"))
If myRng Is Nothing Then
Exit Sub
End If
For Each myCell In myRng.Cells
If IsNumeric(myCell.Value) Then
If Int(myCell.Value) = myCell.Value Then
myCell.NumberFormat = "General"
Else
myCell.NumberFormat = "#,##0.0000"
End If
End If
Next myCell
End Sub
number formatting similar to how this code works but want to execute the code
for columns d through o. I tried changing Me.Range("a:a") with
Me.Range("d") and got a compile error: "invalid use of me keyword".
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRng As Range
Dim myCell As Range
Set myRng = Intersect(Target, Me.Range("a:a"))
If myRng Is Nothing Then
Exit Sub
End If
For Each myCell In myRng.Cells
If IsNumeric(myCell.Value) Then
If Int(myCell.Value) = myCell.Value Then
myCell.NumberFormat = "General"
Else
myCell.NumberFormat = "#,##0.0000"
End If
End If
Next myCell
End Sub