wtorek, 22 września 2015

Autofill a column next to my pasted data.

After I paste new rows into my data I need to fill down some formulas in an adjacent column. What if I would like to make it automatic? I came up so far with this code (in Worksheet module). I paste in my data to columns A through I and the formulas to be pulled down are in columns J through R:
Private Sub Worksheet_Change(ByVal Target As Range)

'Declare Variables
Dim FR As Long, LR As Long

Application.EnableEvents = False
Application.ScreenUpdating = False

'Find first and last row
FR = Sheets("Output3").Cells(Rows.Count, "J").End(xlUp).Row
LR = Sheets("Output3").Cells(Rows.Count, "A").End(xlUp).Row

If FR = LR Then Exit Sub

'Autofill
Range("J" & FR & ":" & "R" & FR).AutoFill Destination:=Range("J" & FR & ":" & "R" & LR)

Application.EnableEvents = True
Application.ScreenUpdating = True
   

Brak komentarzy:

Prześlij komentarz