VBA insert text based on the second letter of a text sting in another cell.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I already have the basic VBA but I just need to fine tune it to pick up ANY letter except the Letter B.
The VBA I'm using is
VBA Code:
Sub Depositioner()
    Dim i As Long
    For i = 1 To ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
        Select Case Left(ActiveSheet.Cells(i, 1).Value, 2)
            Case "AV"
                ActiveSheet.Range("G" & i).Value = ActiveSheet.Range("G" & i).Value & " DEPOSITIONER"
        End Select
    Next i

End Sub

However I need the wildcard the first letter. I tried using both "?V", and "*V". I am hoping to have this apply to any letter or number in the first position with the Exception of the letter B.

Thank you vey much indeed.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try this:

VBA Code:
Sub Depositioner()
  Dim i As Long
  For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
    If Left(Cells(i, 1).Value, 2) Like "*V" Then
      Range("G" & i).Value = Range("G" & i).Value & " DEPOSITIONER"
    End If
  Next i
End Sub
 
Upvote 0
Try this:

VBA Code:
Sub Depositioner()
  Dim i As Long
  For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
    If Left(Cells(i, 1).Value, 2) Like "*V" Then
      Range("G" & i).Value = Range("G" & i).Value & " DEPOSITIONER"
    End If
  Next i
End Sub
That is beautiful, in reference to part B to the question. I just need one little exception to the asterisk. That is I need this rule to be ignored in the first letter is a Letter B. Thank you so much.
 
Upvote 0
That is I need this rule to be ignored in the first letter is a Letter B.
I skipped that part. Try this

VBA Code:
Sub Depositioner()
  Dim i As Long
  For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
    If Left(Cells(i, 1).Value, 2) Like "*V" And Left(Cells(i, 1).Value, 1) <> "B" Then
      Range("G" & i).Value = Range("G" & i).Value & " DEPOSITIONER"
    End If
  Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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