I am wondering if there was any sort of way to assign an array order. Example - If one of the values in the array matches a cell value then assign that to the number 1 spot in the array. Here is the particular methodology I am using.
I do not want to hardcode and list out my entire array in the actual code as this will be dynamic - each import file name could be different.
or put in a simple way; with using Application.GetOpenFileName, I am wondering if there is a way you can assign the LBound() based on a cell value.
All thats really a concern is the Lbound, after it has matched, I don't care about the order after
If I am not mistaken; the general order logic of Lbound to Ubound is to take numerics first then alpha characters, but I also do not want the user to have to modify the import file name.
I also saw another post where there was a Function that could resort from A to Z, but I'd like to avoid Functions as well if I can.
I do not want to hardcode and list out my entire array in the actual code as this will be dynamic - each import file name could be different.
or put in a simple way; with using Application.GetOpenFileName, I am wondering if there is a way you can assign the LBound() based on a cell value.
All thats really a concern is the Lbound, after it has matched, I don't care about the order after
If I am not mistaken; the general order logic of Lbound to Ubound is to take numerics first then alpha characters, but I also do not want the user to have to modify the import file name.
I also saw another post where there was a Function that could resort from A to Z, but I'd like to avoid Functions as well if I can.
Code:
Sub AssignUbound()
Dim eWorkbook, iWorkbook As Workbook
Set eWorkbook = ThisWorkbook
Dim iWorkbookImportOpen As Variant
Dim i As Integer
Application.DisplayAlerts = False: Application.AskToUpdateLinks = False: Application.ScreenUpdating = False: Application.StatusBar = True
chdir eWorkbook.Path
iWorkbookImportOpen = Application.GetOpenFilename(FileFilter:="Excel Workbooks(*.xls; *.xlsx; *.xlsm; *.xltx; *.xltm), *.xls; *.xlsx; *.xlsm; *.xltx; *.xltm", _
Title:="Select Import File(s)", ButtonText:="Select & Import", MultiSelect:=True)
On Error Resume Next
For i = LBound(iWorkbookImportOpen) To UBound(iWorkbookImportOpen)
MsgBox (Left(iWorkbookImportOpen(i), (InStrRev(iWorkbookImportOpen(i), ".", -1, vbTextCompare) - 1)))
Next i
End Sub