If this sub is called via the worksheet "sheetCTF" then it works. If it is called via the worksheet "sheetEXTRACTED" then I get
"Run time error 1004 - Method 'Range' of object '_Worksheet' failed"
Why?
Public Const ctfHeadingRow As Long = 1
Public Const ctfLastRow As Long = 200
Sub SUB_copyCtfColsToExtracted(sourceCol As Long, destCol As Long)
sheetCTF.Range(Cells(ctfHeadingRow, sourceCol), Cells(ctfLastRow,sourceCol)).SpecialCells(xlCellTypeVisible).Copy _
Destination:=sheetEXTRACTED.Range(Cells(extractedFirstRow, destCol).Address)
End Sub
(Sheet are set in different module).
extractedFirstRow
? Is that a public / global variable which is available to the routine? Are thesheetEXTRACTED
andsheetCTF
the actual sheetnames in VBE or are they the tab names? In that case you'd needWorksheets("sheetEXTRACTED")
– Rik SportelextractedFirstRow
is a global variable in a different module. And yes they are both the actual sheet names set in a different module. – Slab