ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Another Auto Fill variable length column (https://www.excelbanter.com/excel-programming/371145-another-auto-fill-variable-length-column.html)

BEEJAY

Another Auto Fill variable length column
 
Greetings:
Am trying to use the following as part of an existing process to copy down
formulas placed in G2 and I2, to variable length columns.

When trying to CALL the Private Sub, I get Error messages as detailed under
each CALL line:

' Copy formulas in G2 and I2 down thru to last used Row

Call Worksheet_Change
' Creates Compile Error: Argument not Optional

Call Worksheet_Change(ByVal Target As Range)
' Creates Compile Error: List seperator or )

End Sub

The following is the code I got from this group.
I understand what it is supposed to do. Hopefully it works OK when the CALL
problem is resolved.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim LRow As Long
If Target.Column = 1 Then
LRow = Cells(Rows.Count, 1).End(x1Up).Row
Application.EnableEvents = False
Range("G2").AutoFill Destination:=Range("G3:G" & LRow)
Range("I2").AutoFill Destination:=Range("I3:I" & LRow)
Application.EnableEvents = True
End If

End Sub


BEEJAY

Another Auto Fill variable length column
 
Please ignore this post. I'm trying to tackle it a different way.


"BEEJAY" wrote:

Greetings:
Am trying to use the following as part of an existing process to copy down
formulas placed in G2 and I2, to variable length columns.

When trying to CALL the Private Sub, I get Error messages as detailed under
each CALL line:

' Copy formulas in G2 and I2 down thru to last used Row

Call Worksheet_Change
' Creates Compile Error: Argument not Optional

Call Worksheet_Change(ByVal Target As Range)
' Creates Compile Error: List seperator or )

End Sub

The following is the code I got from this group.
I understand what it is supposed to do. Hopefully it works OK when the CALL
problem is resolved.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim LRow As Long
If Target.Column = 1 Then
LRow = Cells(Rows.Count, 1).End(x1Up).Row
Application.EnableEvents = False
Range("G2").AutoFill Destination:=Range("G3:G" & LRow)
Range("I2").AutoFill Destination:=Range("I3:I" & LRow)
Application.EnableEvents = True
End If

End Sub



All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com