Dynamic Autofill And Replacing Values

mmertt900

New Member
Joined
Dec 18, 2020
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I couldn't figure out how to solve below problems. I need your advise and ideas.
My first problem is I have a worksheet similar below. What I want to do is autofill cell B(cba) based on the last value in column A(abc column). Below code works fine if I specify start range but the problem is I want it to be dynamic because it is a consolidation macro and it is going to be added new datas in colunm A and column B. What am I doing wrong ?

abccba
abc
abc
abc

VBA Code:
Dim i as integer
Dim StartRow as integer

StartRow= cells(rows.count,2).end(xlup).row
Range("B"&StartRow).AutoFill Destination:=Range("B"StartRow : B" & Range("A" & Rows.Count).End(xlUp).Row)

My second question is actually I need your ideas about it. İn above worksheet I also have a column that specify cities but because of I download this data it comes as code. For exapmle Shanghai comes as CNSHA. There is almost 60 different cities like this. What I want to do replace all of this codes with their real names. I can create another column that explains which code means which city but I don't know what to do next. Thanks in advance for your help.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this:
VBA Code:
Dim i as integer
Dim StartRow as integer

StartRow= cells(rows.count,2).end(xlup).row
Range("B" & StartRow).AutoFill Destination:=Range("B" & StartRow & ":B" & Range("A" & Rows.Count).End(xlUp).Row)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,998
Messages
6,122,643
Members
449,093
Latest member
Ahmad123098

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