VBA: Substitute or Replace A with A2 and H with H2

onlymeami

New Member
Joined
Dec 30, 2016
Messages
5
Hello I've been searching and using the forums for a while but my search fu is weak so I will ask.

I am working on a document that has users enter the letter A or H in a column. Is there a way to replace or substitute that letter with the A2 or H2 respectively. It's not a huge deal but makes the form look nicer.

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
It's a form I made for users to enter Data as it happens. To track temperatures and gases. Some of them Type A2 or H2 but some just put A or H this is just a pet peave of mine. I can get the function to work but I am trying to find a way to put it in VBA so when they enter A it's automatically replaced with A2 and H with H2.

=SUBSTITUTE(G24,"A ","A2") I can do it with "A " and a space but was just curious if anyone could help :)
 
Upvote 0
You don't actually need the space! This will work:

=SUBSTITUTE(G24,"A","A2")

But if you want a VBA solution, then you probably need to edit your opening post title to add VBA to it. If you are unable to do so, then use the report button under your opening post and ask a mod to amend it for you.
 
Upvote 0
You will definitely need VBA because you cannot have both a formula and a value in one cell. Someone will be able to help. Just be patient! :)
 
Last edited:
Upvote 0
Thanks I'll have to do that! I was hoping to figure out a VBA solution
Give this a try...
Code:
Sub ExpandAandHtoA2andH2()
  Columns("G").Replace "A", "A2", xlWhole, , False
  Columns("G").Replace "H", "H2", xlWhole, , False
End Sub
 
Upvote 0
Well after overthinking things as I usually do I figured it out :) Sorry if someone has another solution that's great.

I created two entries A2 and H2 in G24 and G25 and hid the Rows and with the document protected users can just enter "a" and hit enter the "2" is highlighted with auto-fill. I can't believe I never thought of that.
 
Upvote 0

Forum statistics

Threads
1,214,845
Messages
6,121,902
Members
449,053
Latest member
Guy Boot

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