Replace cells in column B based on column A

hotpinkleg

New Member
Joined
Jan 13, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
  2. Web
I feel like this is a basic question but can't figure out how to automate it with a macro.

Example of what I'm trying to do:
Column A has Cities and Column B has the time zone. I need to replace the time zone based on the city to the state it belongs in.

I know how to set it up the slow way of creating a new tab and copying the cities and then in the next column the matching state and then creating the formula but need to make this easy for the rest of my team (ie: click this macro button) if I'm out of office.

CityTime Zone
DetroitEast
New York East
Chicago Central
Dallas Central
Portland West
DenverMountain
Colorado SpringsMountain
LansingEast
San Francisco West
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You still need a table somewhere with matching time zone for a list of cities, but then VLookUp will automatically change column B.
 
Upvote 0
Sorry, I can read VBA code much better than I can write it myself. wouldn't a vlookup just find if the value exists on another table?
I thought I would be using an IFS statement?
 
Upvote 0
Actually, I think an Xlookup formula would be easier

=XLOOKUP((A:A),reference city list,reference cooresponding state list,"")

How do I make this into a VBA macro?
 
Upvote 0
Actually, I think an Xlookup formula would be easier

=XLOOKUP((A:A),reference city list,reference cooresponding state list,"")

How do I make this into a VBA macro?
Even XLookUp need to refer to table too, right?

I'm not sure if I understood your question right. It seems like you do not want a table but even VBA would need to refer to a table somewhere. You would not want to put all the list in code because it would be impractical. :)
 
Upvote 0
It's ok, I figured out how to edit the power bi report so I don't need to edit anything in excel anymore. Thanks!
 
Upvote 0
Solution

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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