Conditional change: Change value in a cell based on specific text (ending in "X") in another column

Bob_C

New Member
Joined
Nov 13, 2019
Messages
4
Hello Board,

I am new to board and dumb, hoping someone would share a simple VBA code

I have a large table of data of ~10000 rows.

I'd like VBA Code to loop through:
1) evaluate data in column A for cells that contains 5 characters ending in letter "X"
2) If it finds such, I'd like to change text in column C to "Group"

For Example: In this it would change C2 and C3 to "Group" since A2 and A3 ID#'s contain 5 letters and end in X

ABC
1ID#AMOUNTTYPE
2RBFCX5001
Single
3TLSHX4006Indiv
4VA98278542Single
5UDGSX9865Group

<tbody>
</tbody>



Thanks for any help
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi & welcome to MrExcel.
How about
Code:
Sub BobC()
    With Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row)
        .Value = Evaluate(Replace("If((len(@)=5)*(right(@)=""X""),""Group""," & .Address & ")", "@", .Offset(, -2).Address))
    End With
End Sub
 
Upvote 0
Thanks for replying Fluff! Your code ran without error, unfortunately it did not replace anything in the worksheet.
 
Upvote 0
FORGIVE ME FLUFF!!! I happened to add a column while experimenting. When I adjusted range it ran successfully.

Thank you very much!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,192
Members
448,554
Latest member
Gleisner2

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