Reputation: 11
I'm new to VBA and have an issue with a command, I've separated it out in to a separate Excel spreadsheet and still can't get it to work.
If I use the following on the active work sheet all is fine
Range(Cells(1, 1), Cells(99, 2)).Value = "Test"
But when I use:
Sheets("one").Range(Cells(1, 1), Cells(99, 2)).Value = "Test"
I receive the error 1004 application defined or object defined error
.
I have the sheet named "one" in my workbook.
I spent the last few hours searching through Google, but no luck, can anyone suggest what is wrong?
Upvotes: 0
Views: 2105
Reputation: 149295
You have to also qualify the Cells()
object
Sub Sample()
With Sheets("one")
.Range(.Cells(1, 1), .Cells(99, 2)).Value = "Test"
End With
End Sub
Upvotes: 4