Hello,
I am using the following VBA code to refresh data in excel worksheets and fill the column A with formula and extend them to the last value row based on column B.
so.Select
so.Cells.ClearContents
so.Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
fcst.Select
fcst.Cells.ClearContents
fcst.Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
so.Select
so.Range("A1").Select
ActiveCell.FormulaR1C1 = "Unique Key"
so.Range("A2").Select
ActiveCell.FormulaR1C1 = "=""SO""&COUNTIF(R2C3:RC[2],RC3)&""-""&RC3"
Selection.AutoFill Destination:=Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
so.Columns("A:A").EntireColumn.AutoFit
I get the error "Autofill Method of Range Class Failed" on the line Selection.AutoFill Destination:=Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
Can anyone help me understand what I am doing wrong here. I am pretty new to VBA.
Thanks
VJ
Bookmarks