multiple values

JOEE1979

Active Member
Joined
Dec 18, 2022
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have a VBA that I've been using for a while.
I would like to add multiple values where I have
If Target.Offset(0, -1).Value = "Running Repair" Then
I have tried
If Target.Offset(0, -1).Value = "Running Repair" Or Target.Offset(0, -1).Value = "Vendor Support" Then
but its not working
What am I doing wrong?
Thank you

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim f As Range
  Dim resp As VbMsgBoxResult
  Dim i As Long

'Running Repair
If Not Intersect(Target, Range("F:F")) Is Nothing Then
    If Target.Count > 1 Then Exit Sub
    If Target.Value = "Completed" Then
    If Target.Offset(0, -1).Value = "Running Repair" Then
      resp = MsgBox("Is unit returned to service?", _
        vbYesNo + vbQuestion)
      If resp = vbYes Then
        Set f = Range("I:J").Find("RETURNED TO SERVICE", , xlValues, xlPart, , , False)
        If Not f Is Nothing Then
          i = f.Row + 2
          Set f = Range("I:J").Find(Range("A" & Target.Row).Value, , xlValues, xlWhole, , , False)
          If Not f Is Nothing Then
            MsgBox "This unit already exists in the section."
            Exit Sub
          End If
          Do While True
            If Range("I" & i).Value = "" Then
              Range("I" & i).Value = Range("A" & Target.Row).Value
              Exit Do
            End If
            i = i + 1
          Loop
        End If
      End If
    End If
  End If
 
  End If
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Although there are other ways to code that, the way you did it should work. So when you say "it's not working" what do you mean? It doesn't find a cell that has "Vendor Support" in it? Have you checked the cell to see if it actually has "Vendor Support" in it EXACTLY? An extra space somewhere can be hard to notice, and it will make it so that the IF doesn't work. If it looks OK, post a section of your table that doesn't work and we can take a look at it.
 
Upvote 0
Solution
Although there are other ways to code that, the way you did it should work. So when you say "it's not working" what do you mean? It doesn't find a cell that has "Vendor Support" in it? Have you checked the cell to see if it actually has "Vendor Support" in it EXACTLY? An extra space somewhere can be hard to notice, and it will make it so that the IF doesn't work. If it looks OK, post a section of your table that doesn't work and we can take a look at it.
My mistake, you are correct
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top