Hi genracela,
I'm sure it was an innocent oversight, but after posting the follow-up question in the other thread, if you think that it actually needs a new thread, you could post a link in the original to the new one. That way, Dusty (rbrhodes) or others don't answer in the old thread while others are responding to the new one. Does that makes sense?
Anyways, here's what I was coming up with as an example. I did not tie it in to your wb, but just a sample userform in case of help in studying how you could use in the code as an alternative to listing the filename on the sheet. Hope it is of help.
Option Explicit
'// Not super well thought through, but maybe enough basics to read through help and get//
'// you going on assigning the source wb via the selection in listbox. //
Private Sub cmdCancel_Click()
MsgBox "Handle non-selection here, or maybe in 'UserForm_QueryClose'", vbInformation, vbNullString
Unload Me
End Sub
Private Sub cmdOK_Click()
MsgBox "I chose: " & Me.lstOpenWorkbooks.Value & vbCrLf & _
"(Assign the value of ""lstOpenWorkbooks"" to a variable here.)", _
vbInformation, vbNullString
Unload Me
End Sub
Private Sub lstOpenWorkbooks_Click()
Me.cmdOK.Enabled = True
End Sub
Private Sub lstOpenWorkbooks_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "I chose: " & Me.lstOpenWorkbooks.Value & vbCrLf & _
"(Assign the value of ""lstOpenWorkbooks"" to a variable here.)", _
vbInformation, vbNullString
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim _
wb As Workbook, _
i As Long, _
bolAdded As Boolean
'// 'Me' in a userform refers to the userform; if used in a worksheet's module, //
'// refers to the sheet. //
With Me
'// These properties can be set in design time; written out so you can see/study//
'// the porperties. //
.Height = 142.5
.Width = 202.5
.Caption = "Select Workbook"
With cmdOK
.Height = 24
.Left = 120
.Top = 62.25
.Width = 72
.Caption = "OK"
.Enabled = False
With .Font
.Bold = True
.Size = 11
End With
End With
With .cmdCancel
.Height = 24
.Left = 120
.Top = 92.25
.Width = 72
.Caption = "Cancel"
With .Font
.Bold = True
.Size = 11
End With
End With
With .lstOpenWorkbooks
.Height = 110.25
.Left = 6
.Top = 6
.Width = 108
.MultiSelect = fmMultiSelectSingle
'// Default value of a Boolean is False, just explicit for clarity //
bolAdded = False
'// Loop thru wb's... //
For Each wb In Workbooks
'// ...skipping thisworkbook... //
If Not wb.Name = ThisWorkbook.Name Then
'// ...adding wb names to the listbox. I chose to alpha-sort //
'// then names on the way in. //
For i = 0 To .ListCount - 1
If wb.Name < .List(i) Then
.AddItem wb.Name, i
bolAdded = True
Exit For
End If
Next
If Not bolAdded Then
.AddItem wb.Name
Else
bolAdded = False
End If
End If
Next
.ListIndex = -1
End With
End With
End Sub