Overdriven Pub
New Member
- Joined
- May 3, 2019
- Messages
- 3
I'm trying to make a spreadsheet such that when the day changes (Cell B2), an operator changes another cell and a third cell is cleared. On top of that, whenever a value is entered into a fourth cell, it is added to a fifth cell and the fourth cell clears. My code is below. When I enter a value in the fourth cell, I get the message "Method 'Value' of object 'Range' failed." When I change Cell B2, no errors or issues arise. When I debug, the fourth line from the bottom is highlighted.
Private Sub Worksheet_Change(ByVal target As Range) Dim KeyCells As Range
Set KeyCells = Range("B2")
If Not Application.Intersect(KeyCells, Range(target.Address)) _
Is Nothing Then
Range("A2").Value = Range("A2").Value - Range("F2").Value
Range("F2").Clear
Range("F2").NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
End If
Set KeyCells = Range("G2")
If Not Application.Intersect(KeyCells, Range(target.Address)) _
Is Nothing Then
Range("F2").Value = Range("F2").Value + Range("G2").Value *THIS LINE IS HIGHLIGHTED WHEN I DEBUG*
Range("G2").Clear
End If
End Sub
Private Sub Worksheet_Change(ByVal target As Range) Dim KeyCells As Range
Set KeyCells = Range("B2")
If Not Application.Intersect(KeyCells, Range(target.Address)) _
Is Nothing Then
Range("A2").Value = Range("A2").Value - Range("F2").Value
Range("F2").Clear
Range("F2").NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
End If
Set KeyCells = Range("G2")
If Not Application.Intersect(KeyCells, Range(target.Address)) _
Is Nothing Then
Range("F2").Value = Range("F2").Value + Range("G2").Value *THIS LINE IS HIGHLIGHTED WHEN I DEBUG*
Range("G2").Clear
End If
End Sub