UserForm with InputBox Method Type 8 Function

austinandrei

Board Regular
Joined
Jun 7, 2014
Messages
117
Hi,
I've been trying to search for ways on how a userform can function as an inputbox of type:=8 but still got no luck.
Basically, what I want is to let the user choose a workbook and a worksheet that is why I use the type:=8 of InputBox method but I want to replicate it using a userform because inputbox lacks ways for formatting labels, boxes, etc unlike userform. Is there a way or I'll just end up using the inputbox? Thanks!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Have you looked at the RefEdit control?
 
Upvote 0
Now I just tried using RefEdit but I can't go to any workbooks except for the activeworkbook. This is also my dilemma in my inputbox now where I can't select a cell in another workbook.
 
Upvote 0
Yes I had that but I am not really sure where the problem lies.
I had this code on Module1:
Code:
Sub test()
UserForm1.Show vbModeless
End Sub
Then I have a userform named Userform1 with Commandbutton as Commandbutton1 then a RefEdit control as RefEdit1.
Then inside my userform code module, I have below:
Code:
Private Sub CommandButton1_Click()
 Dim rRange As Range
 Dim strAddr As String
          strAddr = RefEdit1.Value
          Set rRange = Range(strAddr)
           With rRange
                .Interior.ColorIndex = 3
                .Font.Bold = True
                .BorderAround LineStyle:=xlContinuous, Weight:=xlThick
           End With
Unload Me
End Sub
Now, I was able to go to other workbooks and worksheets but the problem is when the RefEdit1 control is populated, the commandbutton is not functioning and my excel is no longer working.
 
Last edited:
Upvote 0
I saw one code to try but I seem to not have this working as method or data member not found highlighting the "cmbWbName"
I am not sure what to edit to make it work on me:
Code:
Private Sub UserForm_Initialize()
    Dim wb As Workbook
    
    For Each wb In Application.Workbooks
        Me.cmbWbName.AddItem wb.Name
    Next
    Me.cmbWbName = ActiveWorkbook.Name
End Sub
Private Sub cmbWbName_Change()
    Dim sName As String
    
    sName = Me.cmbWbName
    If sName <> "" Then Application.Workbooks(sName).Activate
    Me.txtFullRef = ""
    Me.RefEdit1 = ""
End Sub
Private Sub RefEdit1_Change()
    If RefEdit1.Value <> "" Then
        Me.txtFullRef = "[" & Me.cmbWbName & "]" & Me.RefEdit1
    Else
        Me.txtFullRef = ""
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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
Back
Top