Hi all,
I need to read in a large number of CSV files from one folder into one worksheet, I have code that works and reads the data in, however, one of the values is a 16 digit number, so this is imported in a scientific format.
I have Googled how to fix this by reading files in individually, but can't figure it out when reading in a multitude of files.
My code is below:
Any help on how I can tweak this to display the 16 digit number correctly would be much appreciated.
Thank you in advance.
I need to read in a large number of CSV files from one folder into one worksheet, I have code that works and reads the data in, however, one of the values is a 16 digit number, so this is imported in a scientific format.
I have Googled how to fix this by reading files in individually, but can't figure it out when reading in a multitude of files.
My code is below:
Code:
Sub OpenCSVs()
Dim wb As Workbook
Dim myPath As String
Dim myFile As String
Dim myExtension As String
Dim FldrPicker As FileDialog
Application.EnableEvents = False
Application.DisplayAlerts = False
'Retrieve Target Folder Path From User
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
myPath = .SelectedItems(1) & "\"
End With
Sheets("SMS Log").Range("A:Z").ClearContents
'In Case of Cancel
NextCode:
myPath = myPath
If myPath = "" Then GoTo ResetSettings
'Target File Extension (must include wildcard "*")
myExtension = "*.csv*"
'Target Path with Ending Extention
myFile = Dir(myPath & myExtension)
'Loop through each Excel file in folder
Do While myFile <> ""
'Set variable equal to opened workbook
Set wb = Workbooks.Open(Filename:=myPath & myFile)
'RUN CODE HERE
Loop
ResetSettings:
'Reset Macro Optimization Settings
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Any help on how I can tweak this to display the 16 digit number correctly would be much appreciated.
Thank you in advance.