0

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?

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I forgot how explicit you have to be with VBA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.