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"
 

Some videos you may like

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.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,330
Messages
5,571,570
Members
412,406
Latest member
DutchMonkey
Top