macro doesn't work - invalid forward reference or reference to compiled type

%3CLINGO-SUB%20id%3D%22lingo-sub-1768179%22%20slang%3D%22en-US%22%3Emacro%20doesn't%20work%20-%20invalid%20forward%20reference%20or%20reference%20to%20compiled%20type%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1768179%22%20slang%3D%22en-US%22%3E%3CP%3ERange(%22A9000%22).Select%3C%2FP%3E%3CP%3EWindows(%22Current%20FLC%20Data.xlsm%22).Activate%3C%2FP%3E%3CP%3ESheets(%22English%22).Select%3C%2FP%3E%3CP%3ECells.Select%3C%2FP%3E%3CP%3ESelection.Delete%20Shift%3A%3DxlUp%20Range(%22A1%22).Select%3C%2FP%3E%3CP%3EWindows(%22Current%20Data.xlsm%22).Activate%3C%2FP%3E%3CP%3ESheets(%22English%22).Select%3C%2FP%3E%3CP%3ECells.Select%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20transfer%20of%20data%20works%20for%20the%20the%20first%2C%20but%20not%20to%20Windows(%22Current%20Data.xlsm%22).Activate%3C%2FP%3E%3CP%3ESheets(%22English%22).Select%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1768179%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1768556%22%20slang%3D%22en-US%22%3ERe%3A%20macro%20doesn't%20work%20-%20invalid%20forward%20reference%20or%20reference%20to%20compiled%20type%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1768556%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F827663%22%20target%3D%22_blank%22%3E%40Robert6909%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHow%20about%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3E%20%20%20%20Workbooks(%22Current%20FLC%20Data.xlsm%22).Worksheets(%22English%22).Cells.Clear%0A%20%20%20%20Workbooks(%22Current%20Data.xlsm%22).Worksheets(%22English%22).Cells.Clear%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThis%20assumes%20that%20both%20workbooks%20are%20open.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Range("A9000").Select

Windows("Current FLC Data.xlsm").Activate

Sheets("English").Select

Cells.Select

Selection.Delete Shift:=xlUp Range("A1").Select

Windows("Current Data.xlsm").Activate

Sheets("English").Select

Cells.Select

 

The transfer of data works for the the first, but not to Windows("Current Data.xlsm").Activate

Sheets("English").Select

 

1 Reply
Highlighted

@Robert6909 

How about

    Workbooks("Current FLC Data.xlsm").Worksheets("English").Cells.Clear
    Workbooks("Current Data.xlsm").Worksheets("English").Cells.Clear

This assumes that both workbooks are open.