ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Run-time error '1004': Method 'Range' of object'_Workshe (https://www.excelbanter.com/excel-programming/433059-help-run-time-error-1004-method-range-object_workshe.html)

Ayo

Help with Run-time error '1004': Method 'Range' of object'_Workshe
 
I know that I did something wrong but I don't know what it is. The error
occurs on the second line of code. Any help will be appreciated.
Thanks.

Set goalWS = Worksheets("AAV Goals Update Tables")
goalWS.Range(Cells(cRow, cCol)) = c1

Gary''s Student

Help with Run-time error '1004': Method 'Range' of object'_Workshe
 
You don't need the Range() function. Cells() already give you the range:

Sub dural()
Dim goalWS As Worksheet
Dim c1 As Integer, cRow As Integer, cCol As Integer
cRow = 1
cCol = 1
c1 = 1
Set goalWS = Worksheets("AAV Goals Update Tables")
goalWS.Cells(cRow, cCol) = c1
End Sub

will work just fine.
--
Gary''s Student - gsnu200902


"Ayo" wrote:

I know that I did something wrong but I don't know what it is. The error
occurs on the second line of code. Any help will be appreciated.
Thanks.

Set goalWS = Worksheets("AAV Goals Update Tables")
goalWS.Range(Cells(cRow, cCol)) = c1



All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com