Hello, I recorded the code below using the macro recorder and need some help cleaning it up and making it work.
My goal is to link cell A2 in the sourcedatafile to cell B2 in the file I run this in. The next step is to autofill the range B2:N2 with the data from the same sourcedatafile, and then continue the autofill in the range B2:N6841. When I run this code, it says that the "operation requires the merged cells to be identically sized" and fails on the highlighted line below. Is there a more efficient way of copying the data from the sourcedatafile to this workbook? If there is I would love to hear your thoughts!
Range("A2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR('\\networklink\sourcedatafile!RC[-1],"""")"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:N2"), Type:=xlFillDefault
Range("B2:N2").Select
Selection.AutoFill Destination:=Range("B2:N6841")
Range("B2:N6841").Select
ActiveWorkbook.Worksheets("dATA").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("dATA").AutoFilter.Sort.SortFields.Add Key:=Range( _
"E1:E6841"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("dATA").AutoFilter.Sort
.HEADER = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Bookmarks