I am trying to get Excel to run a macro whenever anything changes in column A from row 4 or below.
I had it working and then I added this line:
openi.Cells(myrow, 1) = UCase(openi.Cells(myrow, 1))
and now if no longer runs, usually it crashes Excel.
Here is the full code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("A4:A99999")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Dim openi As Worksheet
Set openi = Worksheets("OPEN")
myrow = ActiveCell.Row - 1
openi.Cells(myrow, 1) = UCase(openi.Cells(myrow, 1)) '<<<<<<<<<!!!!!!!!!
openi.Cells(myrow, 2) = "=IF(ISNA(VLOOKUP(A" & myrow & ",CUSTINFO!A:B,2,FALSE)),""??"",(VLOOKUP(A" & myrow & ",CUSTINFO!A:B,2,FALSE)))"
If openi.Cells(myrow, 2) = "??" Then
MsgBox ("Customer not found. If customer is new add them to the CUSTINFO tab")
Exit Sub
End If
openi.Cells(myrow, 3).Select
With Sheets("OPEN")
.Columns("A:A").HorizontalAlignment = xlCenter
.Columns("A:A").VerticalAlignment = xlCenter
End With
End If
End Sub
Thanks in advance for any help!
I had it working and then I added this line:
openi.Cells(myrow, 1) = UCase(openi.Cells(myrow, 1))
and now if no longer runs, usually it crashes Excel.
Here is the full code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("A4:A99999")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Dim openi As Worksheet
Set openi = Worksheets("OPEN")
myrow = ActiveCell.Row - 1
openi.Cells(myrow, 1) = UCase(openi.Cells(myrow, 1)) '<<<<<<<<<!!!!!!!!!
openi.Cells(myrow, 2) = "=IF(ISNA(VLOOKUP(A" & myrow & ",CUSTINFO!A:B,2,FALSE)),""??"",(VLOOKUP(A" & myrow & ",CUSTINFO!A:B,2,FALSE)))"
If openi.Cells(myrow, 2) = "??" Then
MsgBox ("Customer not found. If customer is new add them to the CUSTINFO tab")
Exit Sub
End If
openi.Cells(myrow, 3).Select
With Sheets("OPEN")
.Columns("A:A").HorizontalAlignment = xlCenter
.Columns("A:A").VerticalAlignment = xlCenter
End With
End If
End Sub
Thanks in advance for any help!