refedit to select single cell not range

Steve Manning

New Member
Joined
Sep 10, 2002
Messages
3
Hello is there a way to have refedit select the contents of only a single cell? I have a macro that seems to crash because I'm trying to enter (refedit.text) into a single cell. I think it is crashing because the refedit returns a range.
Thanks for any ideas.
Steve
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi Steve,

The problem is not that refedit returns a Range. Even a single cell IS a Range object, albeit a special case. The .Text (and .Value) properties of the Refedit control are not cells or Range objects, they are simply text strings identifying the address of the range. If you want the Range object corresponding to the address string returned by the Refedit object you must use the Range property. For example:

Range(RefEdit1.Text).Value= "Hi there"

puts the string "Hi there" into the cell or cells defined by RefEdit1. If you use the RefEdit to select multiple cells and want the string to be put only in the first cell of the range you can do this:

Range(RefEdit1.Text).Cells(1).Value = "Hi there"

I hope this helps.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,817
Messages
5,574,497
Members
412,598
Latest member
Haven1234
Top