Run-time error '1004': Method 'Range' of object '_Worksheet' failed

J

john.mctigue

The following code is failing on the last line. Has anyone any ideas?

Dim TargetSheet As Worksheet

Set TargetSheet = Application.Workbooks("Summary.xls").Worksheets
("Sheet3")
'Add column headings
TargetSheet.Range(Cells(1, 1)).Value = "Disease Group"

In other posts I have seen people were helped out by qualifying the
cells method with the range, but when I substitute the last line with:
TargetSheet.Range(TargetSheet.Cells(1, 1)).Value = "Disease Group"
it still fails on that line with the same error.

Kind regards,
John
 
D

Dave Peterson

Maybe...

TargetSheet.Cells(1, 1).Value = "Disease Group"
or
TargetSheet.Range("A1").Value = "Disease Group"
 
J

john.mctigue

Maybe...

TargetSheet.Cells(1, 1).Value = "Disease Group"
or
TargetSheet.Range("A1").Value = "Disease Group"











--

Dave Peterson- Hide quoted text -

- Show quoted text -

Dave, thanks for the prompt reply. Syntax 1 above did the trick. Now
on to the next error - I know I'll be back!

Kind regards,
John
 

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