Multiple copy cells downwards

  • Thread starter Thread starter twaccess
  • Start date Start date
T

twaccess

Is there anyone kind enough to provide me with a routine which goes
through a column of data copying the current value into every cell
below it, until it reaches the next new value, where it then copies
that value down to the next value and so on.

The number of rows vary between each item of data so a routine would
have to be relative and not absolute in terms of how it moves between
the relevant values.

E.g. (periods . denote empty row cells)

A
 
A, two solutions. The macro approach:

Sub FillCells()
Dim cell as range
for each cell in selection
if isempty(cell) then cell.value2 = cell.offset(-1,0).value2
next
End sub

You can also find the same feature (and a lot of others) in the Spreadsheet
Assistant available at my site.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
Hi
one way (for column A):
Sub fill_column()
Dim lastrow As Long
Dim row_index As Long
Dim cell_value

lastrow = ActiveSheet.Cells(Rows.count, "A").End(xlUp).row
For row_index = 1 To lastrow
If Cells(row_index, "A").Value = "" Then
Cells(row_index, "A").Value = cell_value
Else
cell_value = Cells(row_index, "A").Value
End If
Next
End Sub
 
Thanks Bob and Frank.

Both solutions worked very well.

Regards

Terry
:
 

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

Back
Top