C
chkoch99
I have written some VBA code which captures a time stamp in column G o
the worksheet when the value in columns B or C is changed. (Code paste
below) When a user clicks on a cell in Column B or C it captures th
current value, then compares it against the new value if the workshee
is changed. My problem is when more than one cell is selected i
columns B or C, the code errors out at the line which it's trying t
capture the value of the cell before it is changed (y = target.value).
How do I write code into the program to only capture the current valu
if only one cell is selected. If more than one cell is selected,
don't want the y = target.value line of code to be executed.
Option Explicit
Dim y As String
Dim x As String
_____________________________________________________________
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
y = Target.Value
End Sub
___________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Long
x = Target.Row
If Target.Column = 2 And y <> Target.Value Or Target.Column = 3 An
y <> Target.Value Then
Cells(x, 7) = Time
Cells(x, 7).NumberFormat = "hh:mm:ss"
End If
End Su
the worksheet when the value in columns B or C is changed. (Code paste
below) When a user clicks on a cell in Column B or C it captures th
current value, then compares it against the new value if the workshee
is changed. My problem is when more than one cell is selected i
columns B or C, the code errors out at the line which it's trying t
capture the value of the cell before it is changed (y = target.value).
How do I write code into the program to only capture the current valu
if only one cell is selected. If more than one cell is selected,
don't want the y = target.value line of code to be executed.
Option Explicit
Dim y As String
Dim x As String
_____________________________________________________________
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
y = Target.Value
End Sub
___________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Long
x = Target.Row
If Target.Column = 2 And y <> Target.Value Or Target.Column = 3 An
y <> Target.Value Then
Cells(x, 7) = Time
Cells(x, 7).NumberFormat = "hh:mm:ss"
End If
End Su