Copy and paste at each change in data

stevod

Board Regular
Joined
Aug 21, 2013
Messages
67
Hi Folks,

Looking for Some code to copy and paste but each time the data changes to fill in the blanks. So in column a and b have are the range.
I want the code to copy a and a and paste it to the where b starts... then copy b and b and copy that to c.... and so on (the values in them cells is different)

It needs to find that range and the last row can be used on "C:C" as this has the data to the last row with no gaps



aa
bb
cc
dd
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I need some help to provide a answer.
With the image you are showing are we seeing column A and B

So when you enter any value into column A or B you want this data copied to column C is that correct.
If not can you help me understand.
 
Upvote 0
i basically want the blanks in columns a and b filled
So whatever is in A1:B1 copy this down until it changes.... then find the next range in A:B and copy this down till it changes
 
Upvote 0
Not sure what till it changes means.
And copy it down in columns A and B I assume
So what does column C have to do with this:
And you want this to happen with a button or as a sheet change event script
 
Upvote 0
so i want it to look like the below,
Yes copy A and B down.... so Select A1:B, copy it and paste it down to banana....
copy banana down to random etc... but the spaces in between is random in size.

Column C can just be used to find the last Row if needed because the last row in C is where it would stop copying to

Sorry, im trying to explain in the best way possible

labellabel
bananabanana
randomramdom
beansbeans


labellabel
labellabel
labellabel
labellabel
bananabanana
bananabanana
bananabanana
bananabanana
randomramdom
randomramdom
randomramdom
randomramdom
beansbeans
beansbeans
beansbeans
 
Upvote 0
Try this:
VBA Code:
Sub Copy_Me_Down()
'Modified 3/12/2020 12:24:22 AM EST
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "C").End(xlUp).Row
For i = 2 To Lastrow
If Cells(i, 1).Value = "" Then Cells(i, 1).Resize(, 2).Value = Cells(i - 1, 1).Value
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Nearly! its copying Column a into b... i want it to copy both A and B together as if they were both selected
 
Upvote 0
Try this:
VBA Code:
Sub Copy_Me_Down()
'Modified 3/12/2020 12:42:30 AM EST
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "C").End(xlUp).Row
For i = 2 To Lastrow
If Cells(i, 1).Value = "" Then Cells(i, 1).Value = Cells(i - 1, 1).Value
If Cells(i, 2).Value = "" Then Cells(i, 2).Value = Cells(i - 1, 2).Value
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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