Dragging values down a range using a colum to determine its length

A

AlexJarvis

Is is possible to write a macro that drags values (or formuals) down a column
to the length of an adjacent column, like when you double click on little
square in the right corner of the box that indicates when a cell is selected?

For this question, I need the formula or data that is in the selected cell
to repeat for all cells in the adjacent column that have values. How do I do
this?
 
M

Mike H

Hi,

Assuming we have something in B1, this fills down col B as far asa there are
data in Col A

Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("B1").AutoFill Destination:=Range("B1:B" & LastRow)
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
M

Mike H

Glad I could help
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
G

Gord Dibben

Assumes formula is in C1 and B has the data.

Sub Auto_Fill()
Dim lRow As Long
With ActiveSheet
lRow = .Range("B" & Rows.Count).End(xlUp).Row
.Range("C1:C" & lRow).FillDown
End With
End Sub

Or if want to use selected cell then fill down.

Sub Auto_Fill()
Dim lRow As Long
With ActiveSheet
lRow = .Range("B" & Rows.Count).End(xlUp).Row
.Range(ActiveCell.Address & ":C" & lRow).FillDown
End With
End Sub



Gord Dibben MS Excel MVP
 

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