Hello,
Column A has general file names, Column B has file names associated with files from Column A and Column C has path to all the files.
Column A-----Column B----- Column C
---AA-------Main Sheet-----D:\AA\Main.xlsb
---AA-------Source Sheet---C:\AA\Source.xlsx
---BB-------Instruction------D:\BB\Instruction.txt
---CC-------Test---------- --D:\CC\Test.docx
I have 2 combobox. First combobox will list files from Column A and second will list files from Column B.
The idea is, if I select AA from first combobox and select Main Sheet from second combobox and click on commandbutton, the userform should open the selected file.
No matter what the file type is, userform should open it. Mostly the files will be
excel,word,text,pdf.
Below are the codes that is used to populate both the comboboxes.
I'm not able to initialise the userform as soon as the sheet opens.
Have attached sample sheet.
Requesting all excel experts to go through the codes and do necessary changes and addition to achieve the idea.
Column A has general file names, Column B has file names associated with files from Column A and Column C has path to all the files.
Column A-----Column B----- Column C
---AA-------Main Sheet-----D:\AA\Main.xlsb
---AA-------Source Sheet---C:\AA\Source.xlsx
---BB-------Instruction------D:\BB\Instruction.txt
---CC-------Test---------- --D:\CC\Test.docx
I have 2 combobox. First combobox will list files from Column A and second will list files from Column B.
The idea is, if I select AA from first combobox and select Main Sheet from second combobox and click on commandbutton, the userform should open the selected file.
No matter what the file type is, userform should open it. Mostly the files will be
excel,word,text,pdf.
Below are the codes that is used to populate both the comboboxes.
Code:
Private Sub cbPrimary_Change()
Dim Name As String, R(), Counter As Integer, I As Integer
Name = cbPrimary.Value
For Counter = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Cells(Counter, 1).Value = Name Then
I = I + 1
ReDim Preserve R(I - 1)
R(I - 1) = Cells(Counter, 2).Value
End If
Next Counter
UFSelection.cmSecondary.List = R
End Sub
Code:
Private Sub UserForm_Initialize()
Dim Counter As Integer
With CreateObject("Scripting.Dictionary")
For Counter = 1 To Cells(Rows.Count, 1).End(xlUp).Row
.Item(Cells(Counter, 1).Value) = ""
Next Counter
cbPrimary.List = .keys
End With
End Sub
I'm not able to initialise the userform as soon as the sheet opens.
Have attached sample sheet.
Requesting all excel experts to go through the codes and do necessary changes and addition to achieve the idea.