VBA excel, able to load even with different file name

shal_llly

New Member
Joined
Sep 25, 2017
Messages
8
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.Calculate
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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
Else
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,657
Latest member
giadungthienduyen

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