Copying varying values down through rows

S

Steve

Hi,

I'd like to copy values from a column down till a new value is encountered
and then start copying that down. Simple I'm sure but I can't seen to get a
start on it.


Here's what I have:

Column A Column B
Value 1 Number
Number
Number
Value 2 Number
Number


Here's what I'd like after running macro:

Column A Column B
Value 1 Number
Value 1 Number
Value 1 Number
Value 2 Number
Value 2 Number


Thanks for the help.
 
D

Dan E

Steve,

Here's a method that uses a helper column (which can later be deleted)
Insert a blank column next to B (ie column C is blank)
In C1: = A1
In C2: = IF(A2="",C1,A2)
Copy C2 down for all of your data
Select Column C and Copy it
Paste Special (Values) into column A
Delete column C

Dan E
 
L

Lance

If I understand you, this should work. Select the range
you want to fill and run the macro.

***Make sure you do a back up first

Sub copyit()
Dim t As Integer, i As Integer
Dim rng As Range
Set rng = Selection
t = rng.Rows.Count
For i = 2 To t
If rng.Cells(i, 1) = "" Then
rng.Cells(i, 1) = rng.Cells(i - 1, 1)
End If
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top