SETTING RANGE VALUE TO ZERO-simple question

navyaa

Board Regular
Joined
Jul 7, 2002
Messages
223
I just want to know how is it possible to set the value of a named range eg ("PYRCHK") to 1 in the simplest form of code..

I can do it using this but was wondering if there is a simpler way of doing it??

Range("PYRCHK").Select
ActiveCell.FormulaR1C1 = "=0"
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Sub myTestVal()
Worksheets("Sheet1").Select
Range("PYRCHK") = 0
End Sub

This works when the named range "PYRCHK" is: "A1" on "Sheet1" for me. JSW
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You do not have to select a range to work with it. And you do not need to use the Formula or FormulaR1C1 properties if you only want to assign a value.

So:

Range("PYRCHK").Value = 0

will do the trick.

Also since Value is the default property of a range object you can shorten it even further:

Range("PYRCHK") = 0

I don't do that myself because it makes the code less readable.
 

navyaa

Board Regular
Joined
Jul 7, 2002
Messages
223
thank you....

all worked great:)

Hope you all have a good day:)

Navya.
 

Forum statistics

Threads
1,147,738
Messages
5,742,899
Members
423,760
Latest member
photogfrog

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
Top