Usually with a subscript out of range error, something is misspelled. This time I can guarantee that it is not misspelled. I am declaring workbook and sheets names as variables to be used later for simple copy paste stuff. But when I define one of my sheets as Set main=wb.Sheets("Primary")
I get the error, subscript out of range. I did't believe it, so I copied what I wrote and pasted that as the Sheet name. Same error. Therefore, their must be an issue with how I set up my Workbook/Worksheets. Any help much appreciated.
Sub copyPaste()
Dim wb As Workbook
Dim main As Sheets
Dim hypo As Sheets
Set wb = ThisWorkbook
Set main = wb.Sheets("Primary")
Set hypo = wb.Sheets("Hypo")
Application.CutCopyMode = False
wb.main.Range("D22:D46").Value = wb.main.Range("D22:D46").Value
End Sub
"Primary"
and not e.g."Primary "
? – John Coleman