I use this code to fill in blanks in one of my workbooks.

'Summary By Unit and Category
                                    ActiveWorkbook.Sheets("Summary By Unit and Category").Select
                                    Range("A19:A" & Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Row).Select
                                    
                                    'Fill in gaps using data above
                                    Selection.SpecialCells(xlCellTypeBlanks).Select
                                    Selection.FormulaR1C1 = "=R[-1]C"
                                    'Make static
                                    With ActiveSheet.UsedRange
                                        .Copy
                                        .PasteSpecial xlPasteValuesAndNumberFormats
                                        .PasteSpecial xlPasteColumnWidths
                                        .PasteSpecial xlPasteFormats
                                    End With

It selectes data in one column based on the amount of rows in another and then just fills in the blank cells based on what's above.

Unfortunately, it's not working in another sheet.

I get a complie error: Expected function or variable and Selection on the 4th line is highlighted.


Any ideas?

Thanks