VBA excel, able to load even with different file name


New Member
Sep 25, 2017
HI all!,

i was asked to make the files to load in the excel more robust. Meaning the excel has to be able to load two files of different name and format to produce an output. keeping in mind format as in the the way the file is named. i have tried to do some codes myself but it would not load unless both their names or their format are the same. not sure where i go wrong as i am quite new to the VBA scene. hope someone would help me out! below is my code that i wrote.

Sub loadone() 'load data for input1

Application.Calculation = xlManual
Application.ScreenUpdating = False

Call clearinputone
Dim inputone As String, columnIndexOne As Integer
inputone = Application.GetOpenFilename("Calc Files (*.cal), *.cal") 'windows explorer + select .cal file
If "" <> inputone Then
columnIndexOne = 2
Call loadFileOne(inputone, columnIndexOne)
Worksheets("Tool").range("B6").Value = inputone 'displays file path and name

Call loadtwo
Call nameformat
Exit Sub
End If
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


New Member
Sep 25, 2017
okay apologies, i copied the wrong code. this would be correct one

Sub checktimeframe() 'Ensures that comparisons are 1Day-1Day/1Month-1Month etc
Dim fileoone, filettwo As String '8th position caters for eg. 7day and 1day files
fileoone = Worksheets("Data").range("A1").Value
fileoone = Right(fileoone, 8) ' ^

filettwo = Worksheets("Data").range("E1").Value
filettwo = Right(filettwo, 8)

If fileoone <> filettwo Then
MsgBox ("Files are of different time inputs eg. Day/Month instead of Day/Day") 'Error if different timeframe,force exit
End If
End Sub

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...