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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Sub myTestVal()
Worksheets("Sheet1").Select
Range("PYRCHK") = 0
End Sub

This works when the named range "PYRCHK" is: "A1" on "Sheet1" for me. JSW
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,065
Members
448,942
Latest member
sharmarick

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