P
purplehaz
I'm writing some code(in excel, visual basic). The following code is
attached to the click action of a button.
Private Sub cmdNewPayApp_Click()
Sheets("Pay App").Visible = True
Sheets("Pay App").Select
Sheets("Pay App").Copy After:=Sheets(2)
Sheets("Pay App (2)").Select
Sheets("Pay App (2)").Name = "Pay App 1"
Sheets("Pay App").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Pay App 1").Select
Range("O11").Select
ActiveCell.Formula = "=A18"
Range("O13").Select
ActiveCell.Formula = "=A19"
Range("O15").Select
ActiveCell.Formula = "=A20"
Range("O17").Select
ActiveCell.Formula = "=A21"
Range("A3").Select
End Sub
When it gets to the code: Range("O11").Select
I always get this error:
Run-time error '1004'
Select method of range class failed.
I thought the syntax is correct. Anyone know why the error occurs?
BTW - if I divide the code into two parts attaching the second part(error
part) to it's own button click action, run the first part, then click the
second button and run the second part it works fine. Why does it not work
together?
Thanks for any help.
attached to the click action of a button.
Private Sub cmdNewPayApp_Click()
Sheets("Pay App").Visible = True
Sheets("Pay App").Select
Sheets("Pay App").Copy After:=Sheets(2)
Sheets("Pay App (2)").Select
Sheets("Pay App (2)").Name = "Pay App 1"
Sheets("Pay App").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Pay App 1").Select
Range("O11").Select
ActiveCell.Formula = "=A18"
Range("O13").Select
ActiveCell.Formula = "=A19"
Range("O15").Select
ActiveCell.Formula = "=A20"
Range("O17").Select
ActiveCell.Formula = "=A21"
Range("A3").Select
End Sub
When it gets to the code: Range("O11").Select
I always get this error:
Run-time error '1004'
Select method of range class failed.
I thought the syntax is correct. Anyone know why the error occurs?
BTW - if I divide the code into two parts attaching the second part(error
part) to it's own button click action, run the first part, then click the
second button and run the second part it works fine. Why does it not work
together?
Thanks for any help.