I'm trying to modify code that bebo021999 helped with here.
The original code works perfectly, but now I'm trying to modify it so I can assign it to a 'button' (ie excel shape) that will look at all cells in the range and update any number to the correct rounding.
I've tried a few variations, and here's where I'm at (the original code after).
Original code:
The original code works perfectly, but now I'm trying to modify it so I can assign it to a 'button' (ie excel shape) that will look at all cells in the range and update any number to the correct rounding.
I've tried a few variations, and here's where I'm at (the original code after).
VBA Code:
Private Sub Rnd()
Dim Target As Range
Set Target = ThisWorkbook.Sheets("MS.combined").Range("H6:H25000")
Application.EnableEvents = False
For Each Cell In Target
If IsNumeric(Cell.Value) And Not IsEmpty(Cell.Value) Then
Cell.Value = Evaluate("ROUND(" & Cell.Address & "/365,2)*365")
End If
Next Cell
Application.EnableEvents = True
End Sub
Original code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Do nothing if range does not change OR text value OR cell is deleted
If Intersect(Target, Range("I2:I6000")) Is Nothing Or _
Not IsNumeric(Target) Or IsEmpty(Target) Then Exit Sub
With Application
.EnableEvents = False
Target.Value = Evaluate("ROUND(" & Target.Address & "/365,2)*365")
.EnableEvents = True
End With
End Sub