RefEdit (ref)

Ref Edit - This control allows the user to select a range of cells in Excel.

Additional Reference

References - RefEdit.Ctrl

There are a few things to keep in mind when you are using this control

The RefEdit control returns a text string that represents a range address
You can convert this string to a range object using the following statement:

Set objRange = Range(RefEdit.Text) 

It is a good idea to initialise this control to display the current selection

RefEdit.Text = ActiveWindow.RangeSelection.Address 

Do not always assume that it will always return a valid range address.
The user can also type directly into this control so you need to make sure the value entered is valid.
You cannot assume the selection made is on the same worksheet as the user may select worksheet tabs.
If a different sheet is selected the range is preceded by the name of the sheet

If you only need a single cell you can obtain the top left cell from the range

objCell = Range(RefEdit.Text).Range("A1") 

You should always put this control directly onto a userform, do not place it inside any other controls (for example frames)
Never make a userform modeless if it contains a RefEdit control.





RefEdit -
RefEdit -

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext