1

So for an early stab at VBA I'm writing a macro:

  1. I'm pasting in a set of data that increases in numbers of rows each month; data is well organised with no blank values/columns
  2. I have formulae in columns A-L and my data is dropped into columns L-onwards
  3. I want to update formulae/columns in A-L to fill down to match the last value in column M

Struggling so if you are able to help with an explanation that would be really appreciated. I know it involved selecting the last row in the A:L - I've got that but I can't work out how to cleanly fill down to match a varying length column M each time.

Sub Macro6()
'
' Macro6 Macro
'

'
    Range("M1").Select
    Range(Selection, Selection.End(xlDown)).Select
    ActiveCell.Offset(0, -1).Select
    Range(Selection, Selection.End(xlToLeft)).Select
    Range(Selection, Selection.End(xlUp)).Select
    Selection.FillDown
End Sub
  • Without providing your code, how can we help you? – Raystafarian Jun 16 '15 at 14:25
  • cheers @Raystafarian added. – Uncle Boz Jun 16 '15 at 15:07
0

Sure you can use the top snippet (lrow) to get the bottom row, and then just use that in your other methods

Sub test()
Dim lrow As Integer
lrow = Cells(Rows.Count, "M").End(xlUp).row
 Range("A1:A" & lrow).FillDown
 Range("B1:B" & lrow).FillDown
End Sub
  • @UncleBoz if this solves your question, go ahead and click the green checkmark next to the answer to indicate the question has an answer. – Raystafarian Jun 16 '15 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.