How to copy data automatically

Howdy1

Board Regular
Joined
Aug 13, 2008
Messages
50
Hi,

I try to figure out a way to copy data dynamically. There are about 45,000 rows in the spreadsheet and there are two columns that I need to copy down. Column A lists the hierarchy key and column B lists the name. Until it hits another different key, the cell will be empty. However, for data extraction purpose, I need to know each line item belongs to which hiearchy. Thus, I need to copy the data from the hiearchy down until another hiearchy populates and procesess repeats itself. I can manually copy the data but like to know how I can code the VBA to copy it dyanmically?

----example

ColA ColB Colc Amount
Ups Upstream lx.343.31 $2
sx.433.12 $1
Dws Downstream lx.433.13 $1
dx.313.31 $2




Any advice is greatly appreciated!

Howdy
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Untested
Code:
Sub Fanugi()
Dim cl as Range
For Each cl in Range("$A$2:$A" & Range("$A$65536").End(xlUp).Row)
If cl = "" Then cl = Cells(cl.Row-1,1)
Next cl
End Sub
lenze
 
Upvote 0
Thank you very much! Sorry that I am still a newbie to VBA code. I understand the code provided is to use the search for the row. How will I identify the starting point and the next data point to copy the data? Where the code should be inserted? After the else?
 
Upvote 0

Forum statistics

Threads
1,214,393
Messages
6,119,261
Members
448,880
Latest member
aveternik

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