I'm new to vba and I've done a lot of research online but still can't figure out this one.
Sub DailyFundRecMacro()
Dim rng As Range
Dim wks As Worksheet
' Prevents screen refreshing.
Application.ScreenUpdating = False
Worksheets("FIMCO Data").Activate
Set wks = Worksheets("FIMCO Data")
Set rng = wks.Range(("E1"), Range("E1").End(xlDown))
Sheets("Converter").Select
Range("E1").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=rng, Type:=xlFillDefault
'Loop all the cells in range
For Each cell In Range("E1:E398")
If Application.WorksheetFunction.IsNA(cell) Then
'If cell contains #N/A, then set the value to 0
cell.Value = 0
End If
Next
Range("B1:E1").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Trial Balance Values").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Problematic line:
Selection.AutoFill Destination:=rng, Type:=xlFillDefault
When I Set rng = wks.Range(("E1"), Range("E1").End(xlDown))
, the autofill won't work, but when I simply use Selection.AutoFill Destination:=Range(("E1"), Range("E1").End(xlDown))
, the code works fine.
Any help is appreciated. Thanks!