ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What is wrong with this range??? (https://www.excelbanter.com/excel-programming/413677-what-wrong-range.html)

Geoff ML[_2_]

What is wrong with this range???
 
NextGameCounter, x and y are all integers. GoalieX is defined as an object.
AwayTeamPage is defined as a worksheet and is used several times earlier in
code without any issues.

i get the error message Method 'Range ' of object '_Worksheet' failed. i
don't get it.

For y = 1 To 9
Set GoalieX = AwayTeamPage.Range("GOALIE" & y)
For x = 1 To 3
AwayTeamPage.Range(GoalieX).Cells(4 + NextGameCounter, -3) =
AwayTeamPage.Range("g6").Cells(NextGameCounter, -1 + x)
Next x
Next y

Tom Ogilvy

What is wrong with this range???
 
so you have defined names/named ranges Goalie1 to Goalie9

then

For y = 1 To 9
Set GoalieX = AwayTeamPage.Range("GOALIE" & y)
For x = 1 To 3
GoalieX.Cells(4 + NextGameCounter, -3) = _
AwayTeamPage.Range("g6").Cells(NextGameCounter, -1 + x)
Next x
Next y

should work although I don't see NextGameCounter getting changed within your
loop and GoalieX must refer to a location in column D or farther to the
right.

--
Regards,
Tom Ogilvy




"Geoff ML" wrote:

NextGameCounter, x and y are all integers. GoalieX is defined as an object.
AwayTeamPage is defined as a worksheet and is used several times earlier in
code without any issues.

i get the error message Method 'Range ' of object '_Worksheet' failed. i
don't get it.

For y = 1 To 9
Set GoalieX = AwayTeamPage.Range("GOALIE" & y)
For x = 1 To 3
AwayTeamPage.Range(GoalieX).Cells(4 + NextGameCounter, -3) =
AwayTeamPage.Range("g6").Cells(NextGameCounter, -1 + x)
Next x
Next y


Geoff ML[_2_]

What is wrong with this range???
 
thanks a lot

[email protected]

What is wrong with this range???
 
On Jul 7, 7:18*pm, Geoff ML wrote:
NextGameCounter, x and y are all integers. GoalieX is defined as an object.



All times are GMT +1. The time now is 04:50 PM.

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