Hi
I have a worksheet where I am using some code to moitor a number of cells for a value. If this value is entered, I want a variable to increase by one. The variable starts at zero. When the value of the variable reaches 14 I want another cell to display a different value. The code I currently have is as follows:
The first section with value DF works fine and my user form appears. Its the next 2 sections I am having issues with. So basically if one of the cells is DNF or N/A I want the variable imref8 to increase by 1. However I change one of the cells to DNF, and msgbox shows me the variable is one. which is correct, however if i enter DNF in the next cell, msgbox shows me the variable is still one. How come the variable isnt incrementing with each DNF or N/A entry?
I have a worksheet where I am using some code to moitor a number of cells for a value. If this value is entered, I want a variable to increase by one. The variable starts at zero. When the value of the variable reaches 14 I want another cell to display a different value. The code I currently have is as follows:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim imref8 As Integer
imref8 = 0
ElseIf Not Intersect(Target, Range("M43:M48, M51:M54, M56:m59")) Is Nothing Then
If Target.Value = "DF" Then
tyres.Show
End If
If Target.Value = "NDF" Then
imref8 = imref8 + 1
MsgBox (imref8)
End If
If Target.Value = "N/A" Then
imref8 = imref8 + 1
MsgBox (imref8)
End If
end sub
The first section with value DF works fine and my user form appears. Its the next 2 sections I am having issues with. So basically if one of the cells is DNF or N/A I want the variable imref8 to increase by 1. However I change one of the cells to DNF, and msgbox shows me the variable is one. which is correct, however if i enter DNF in the next cell, msgbox shows me the variable is still one. How come the variable isnt incrementing with each DNF or N/A entry?