add specific character in the beginning of item into column

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
469
Office Version
  1. 2019
hello
I would add BS in the beginning of item for each cell into column B
list.xlsx
B
1BRAND
2 175/70R13 B25 INDO
3 175/70R13 EP150 THI
4 185/70R13 EP150 INDO
5 175/65R14 EP150 THI
6 175/65R14 B25 INDO
7 175/70R14 EP150 THI
8175/70R14 MY02 THI
9 185/65R14 TEC THI
10 185/65R14 150EZ INDO
11 185/65R14 EP150 INDO
12 195/70R14 150EZ INDO
13 185/65R15 TC10 INDO
14 185/65R15 T005 INDO
15 185/65R15 T01 JAP
16 185/65R15 B250 JAP
17 195/60R15 AR20 INDO
18 195/60R15 EP150 THI
19 195/60R15 T001 JAP
1

result
list.xlsx
B
1BRAND
2BS 175/70R13 B25 INDO
3BS 175/70R13 EP150 THI
4BS 185/70R13 EP150 INDO
5BS 175/65R14 EP150 THI
6BS 175/65R14 B25 INDO
7BS 175/70R14 EP150 THI
8BS 175/70R14 MY02 THI
9BS 185/65R14 TEC THI
10BS 185/65R14 150EZ INDO
11BS 185/65R14 EP150 INDO
12BS 195/70R14 150EZ INDO
13BS 185/65R15 TC10 INDO
14BS 185/65R15 T005 INDO
15BS 185/65R15 T01 JAP
16BS 185/65R15 B250 JAP
17BS 195/60R15 AR20 INDO
18BS 195/60R15 EP150 THI
19BS 195/60R15 T001 JAP
1

thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Is there something you're not telling us that goes beyond "BS " & text ???
 
Upvote 0
How about
VBA Code:
Sub abdomeghari()
   With Range("B2", Range("B" & Rows.Count).End(xlUp))
      .Value = Evaluate("if({1},""BS ""&trim(" & .Address & "))")
   End With
End Sub
 
Upvote 0
@Fluff thanks for the code, but may you fix the code? I don't want to repeat adding BS for many times if I run the code more than time .

it should just add one time even if I run macro repeatedly
 
Upvote 0
You never said anything about that before & when questioned you said
just two letters BS not more , not less
Which is exactly what the code does.

If you cannot be bothered to give correct & accurate information at the start, why should members waste their time trying to help you?
 
Upvote 0
based on picture I thought when run the macro should achieve it without problem, but accidentally ,I ran the macro more than time shows this problem.
list.xlsx
B
1BRAND
2BS BS 175/70R13 B25 INDO
3BS BS 175/70R13 EP150 THI
4BS BS 185/70R13 EP150 INDO
5BS BS 175/65R14 EP150 THI
6BS BS 175/65R14 B25 INDO
7BS BS 175/70R14 EP150 THI
8BS BS 175/70R14 MY02 THI
9BS BS 185/65R14 TEC THI
10BS BS 185/65R14 150EZ INDO
11BS BS 185/65R14 EP150 INDO
12BS BS 195/70R14 150EZ INDO
13BS BS 185/65R15 TC10 INDO
14BS BS 185/65R15 T005 INDO
1

I don't expect to occur that , if I know to happen this case , from normal I will inform you in OP , sorry !
 
Upvote 0
How about
VBA Code:
Sub abdomeghari()
   With Range("B2", Range("B" & Rows.Count).End(xlUp))
      .Value = Evaluate(Replace("if(left(@,2)=""BS"",@,""BS ""&trim(" & .Address & "))", "@", .Address))
   End With
End Sub
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,066
Messages
6,128,571
Members
449,458
Latest member
gillmit

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