![]() |
Run-time error '1004': Method 'Range' of object '_Worksheet' failed
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 |
Run-time error '1004': Method 'Range' of object '_Worksheet' failed
Maybe...
TargetSheet.Cells(1, 1).Value = "Disease Group" or TargetSheet.Range("A1").Value = "Disease Group" wrote: 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 -- Dave Peterson |
Run-time error '1004': Method 'Range' of object '_Worksheet'failed
On Mar 6, 12:17*pm, Dave Peterson wrote:
Maybe... TargetSheet.Cells(1, 1).Value = "Disease Group" or TargetSheet.Range("A1").Value = "Disease Group" wrote: 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 -- 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 |
All times are GMT +1. The time now is 04:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com