What’s the best method to assign a range?

razzandy

Active Member
Joined
Jun 26, 2002
Messages
400
Office Version
  1. 2007
Platform
  1. Windows
Let’s say I have 3 sheets in a workbook, 1st sheet is named Jan, second Feb, and third Mar.

If the active sheet is Jan and I wanted to apply the value from a userForm textbox to sheet Mar A1, I’ve been trying to use code similar to this but I get an error:

Range(“Mar!A1”).value = TextBox.value

So I change it to this

Sheets(“Mar”).Select
Range(“A1”).Value = TextBox.Value
Sheets(“Jan”).Select

This works fine but it just doesn’t seem efficient and it doesn’t look professional due to the screen flickering as it selects the different sheets. I know I can use:

Application.ScreenUpdating = False

But again it just doesn’t seem efficient!

I’ve also tried code like Sheets(“Mar”!Range(“A1”) but again I get errors.

Can anybody, somebody show me what code I should be using??? :sad:

Many Thanks in advance!

Ryan UK :smile:
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
On 2002-09-19 10:43, razzandy wrote:
Let’s say I have 3 sheets in a workbook, 1st sheet is named Jan, second Feb, and third Mar.

If the active sheet is Jan and I wanted to apply the value from a userForm textbox to sheet Mar A1, I’ve been trying to use code similar to this but I get an error:

Range(“Mar!A1”).value = TextBox.value

So I change it to this

Sheets(“Mar”).Select
Range(“A1”).Value = TextBox.Value
Sheets(“Jan”).Select

This works fine but it just doesn’t seem efficient and it doesn’t look professional due to the screen flickering as it selects the different sheets. I know I can use:

Application.ScreenUpdating = False

But again it just doesn’t seem efficient!

I’ve also tried code like Sheets(“Mar”!Range(“A1”) but again I get errors.

Can anybody, somebody show me what code I should be using??? :sad:

Many Thanks in advance!

Ryan UK :smile:

worksheets("Mar").range("A1").value=textbox.value

and so on....

(this may not be the best way, but it avoids having to select a load of stuff....)
 
Upvote 0
Cheers Chris

Thats just what I wanted!! :smile: :wink:

Thank u very much'nes

Ryan UK :smile:
 
Upvote 0

Forum statistics

Threads
1,226,390
Messages
6,190,739
Members
453,615
Latest member
robbieb29

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