How to change a word/number to another word automatically using VBA

fmorenojr

New Member
Joined
Jun 22, 2023
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Good morning, everyone,

I am working on a spreadsheet for my manager. We use a number system for locations that we have in our organization. What I am trying to do is once the number is added into a cell, it would automatically change to the location. I tried looking for a code online but maybe I wasn't as descriptive in the search bar as i was not able to produce results.

For example, if someone puts "02" in any cell under D, it will change to "02 - Storefront." if someone puts "03" in any cell under D, it will change to "03 - Call Center" and so forth. I have 14 locations that I have to add. I am not sure if I VBA used would house all the locations or would the VBA be used individually for each location.

any assistance is greatly appreciated.
 
I set up a test sheet and a worksheet "Locations" with a lookup table and the code worked for me.

1. What line generated that message?
2. Do you really need to format col D as text? If the idea is for users to simply be able to type in a number 1,2,3 and have it be replaced with a location string, why complicate things by making them type in "01" or "02"? It would be simpler to just use numbers 1,2,3, etc and search for them. @6StringJazzer's code works fine for that.

Cell Formulas
RangeFormula
B1:B7B1=RIGHT("00" & A1,2) & " - " & C1
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
If the idea is for users to simply be able to type in a number 1,2,3 and have it be replaced with a location string, why complicate things by making them type in "01" or "02"? It would be simpler to just use numbers 1,2,3, etc and search for them.
That is true, but I was taking the OP literally when it said "type in 02". It could just as easily use integers.
 
Upvote 0
Seems like it was user error on my part. I created the sheet as locations, but never created a lookup table. thank you both 6StringJazzer and rlv01 on your assistance on this on.

 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,206
Members
453,022
Latest member
RobertV1609

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