Sorry, but I've spent an hour looking for answers for this problem, and although google returns thousands (probably) of pages of results, I can't find an answer.
I was basically wondering if there are any properties that a worksheet holds that stops it from being selected / copied via vba code. I've manually selected and copied the sheet, but basic vba code fails.
It was failing at the select line (I inherited this code, no idea why it was being selected), but also fails at the copy line, which looks fine to me.
Any ideas? Thanks.
I was basically wondering if there are any properties that a worksheet holds that stops it from being selected / copied via vba code. I've manually selected and copied the sheet, but basic vba code fails.
Code:
Dim pNum As Integer
Dim i As Integer
Dim wb As Workbook
Set wb = ActiveWorkbook
Application.ScreenUpdating = False
'Message box to enter the number of projects
pNum = Application.InputBox _
(Prompt:="How many projects? If no projects, type '0'", Title:="Projects", Type:=1)
If pNum = 0 Then
Exit Sub
Else
'Creating summary worksheet
'Sheets(2).Select
wb.Sheets(2).Copy After:=wb.Sheets(2)
Sheets(3).Name = "Summary"
It was failing at the select line (I inherited this code, no idea why it was being selected), but also fails at the copy line, which looks fine to me.
Any ideas? Thanks.
Last edited: