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
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,437
Messages
5,831,620
Members
430,077
Latest member
CoulterM

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