RefEdit (ref)

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

microsoft excel docs

Additional Control / Reference

Name - RefEdit.Ctrl

microsoft excel docs

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 - http://blogs.msdn.com/gabhan_berry/archive/2008/06/12/net-refedit-control.aspx
RefEdit - http://www.codeproject.com/KB/selection/RefEditControl.aspx


Alternative

Use a regular textbox instead called "txtRefEdit".

Private Sub UserForm_Initialize() 
    Me.txtRefEdit.DropButtonStyle = fmDropButtonStyleReduce
    Me.txtRefEdit.ShowDropButtonWhen = fmShowDropButtonWhenAlways
End Sub

Private Sub txtRefedit_DropButtonClick()
    Dim var As Variant
    Dim rng As Range
    Dim sFullAddress As String
    Dim sAddress As String
    Me.Hide
    On Error Resume Next
    var = Application.InputBox("Select the range containing your data", "Label Range", _
                               Me.txtRefEdit.Text, Me.Left + 2, Me.Top - 86, , , 0)
    On Error GoTo 0
    If TypeName(var) = "String" Then
        CheckAddress CStr(var)
    End If
    Me.Show
End Sub

Properties

AutoSize 
AutoTab 
AutoWordSelect 
BackColor 
BackStyle 
BorderColor 
BorderStyle 
ControlTipText 
DragBehavior 
Enabled 
EnterFieldBehavior 
EnterKeyBehavior 
Font 
ForeColor 
Height 
HelpContextID 
HideSelection 
IMEMode 
IntegralHeight 
Left 
Locked 
MaxLength 
MouseIcon 
MousePointer 
MultiLine 
PasswordChar 
ScrollBars 
SelectionMargin 
SelLength 
SelStart 
SelText 
SpecialEffect 
TabIndex 
TabKeyBehavior 
TabStop 
Tag 
Text 
TextAlign 
Top 
Value 
Visible 
Width 
WordWrap 

Events

AfterUpdate 
BeforeDragOver 
BeforeDragOrPaste 
BeforeUpdate 
Change 
DblClick 
DropButtonClick 
Enter 
Error 
Exit 
KeyDown 
KeyPress 
KeyUp 
MouseDown 
MouseMove 
MouseUp 

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