sheets.range problem

paul_taylor

New Member
Joined
Feb 15, 2011
Messages
33
This code works for me

range(cells(variable1,1),cells(10,variable2)). value = 1

This code doesn't work

sheets(1).range(cells(variable1,1),cells(10,variable2)).value = 1

Why not? :(

The reason I need this is I need to get to

sheets(2).range(cells(variable1,1),cells(10,variable2)) = sheets(1).range(cells(variable1,1),cells(10,variable2)).value

or something like that.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try something like this...
Code:
[COLOR="Red"]Sheets(1).[/COLOR]Range([COLOR="Red"]Sheets(1).[/COLOR]Cells(variable1,1), [COLOR="Red"]Sheets(1)[/COLOR].Cells(10,variable2)).Value = 1

Or better yet...
Code:
With Sheets(1)
    [COLOR="Red"].[/COLOR]Range([COLOR="Red"].[/COLOR]Cells(variable1,1), [COLOR="Red"].[/COLOR]Cells(10,variable2)).Value = 1
End With
 
Upvote 0
Try something like this...
Code:
[COLOR="Red"]Sheets(1).[/COLOR]Range([COLOR="Red"]Sheets(1).[/COLOR]Cells(variable1,1), [COLOR="Red"]Sheets(1)[/COLOR].Cells(10,variable2)).Value = 1

Or better yet...
Code:
With Sheets(1)
    [COLOR="Red"].[/COLOR]Range([COLOR="Red"].[/COLOR]Cells(variable1,1), [COLOR="Red"].[/COLOR]Cells(10,variable2)).Value = 1
End With


Worked. ****. Nice job.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top