error 1004

B

BobAtVandy

This has to be so simple that I'm sure I'll be embarassed, but I'm new to
VBA and haven't been able to figure it out after several hours.

I created a very simple VBA function which simply tries to stuff a value
into a cell on a worksheet.
But I get error 1004 -- "Application-defined or object-defined error"

Function TestCopy()
On Error GoTo ErrHandler
Worksheets("ETF Data").Range("H11").Value = "testdata"
TestCopy = 1
Exit Function
ErrHandler:
MsgBox Err.Number & " : " & Err.Description
TestCopy = 0
End Function


I can assure you that the named worksheet, "ETF Data" exists. And, when I
fetch values from the sheet [[ e.g.,
x = Worksheets("ETF Data").Range("H11").Value ]] it works.

Can someone PLEASE tell me what is going on?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top