Hi there, I have two pieces of code put together so that the Open recent file one runs first and then the Split words code. The only problem is the split words code runs in the file the open recent file code opens, but it should Split the words in the master workbook. Is there a way to make the Split words code split the words in the master workbook only
Thanks
Split Words Code
Sub SplitWords()
n = Application.WorksheetFunction.CountA(Range("A:A"))
For r = 1 To n
cadena = Cells(r, 1)
l = Len(cadena)
i = 1
k = 2
Do
j = i
Do
letra = Mid(cadena, i, 1)
i = i + 1
Loop Until letra = "," Or i > l
word = Mid(cadena, j, i - j - 1)
Cells(r, k) = word
k = k + 1
Loop Until i > l
Next
End Sub
Code Put together
Option Explicit
Sub NewestFile()
Dim MyPath As String
Dim MyFile As String
Dim LatestFile As String
Dim LatestDate As Date
Dim LMD As Date
Dim wbMaster As Workbook
Dim wbLatest As Workbook
Set wbMaster = ThisWorkbook
MyPath = "C:\Users\lfinc\OneDrive\Documents\Officiating\New Results system\For LIF Files"
If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
MyFile = Dir(MyPath & "*.LIF", vbNormal)
If Len(MyFile) = 0 Then
MsgBox "No files were found...", vbExclamation
Exit Sub
End If
Do While Len(MyFile) > 0
LMD = FileDateTime(MyPath & MyFile)
If LMD > LatestDate Then
LatestFile = MyFile
LatestDate = LMD
End If
MyFile = Dir
Loop
Set wbLatest = Workbooks.Open(MyPath & LatestFile)
' Clear some stuff
wbMaster.Worksheets("Data Sorter").Cells.Clear
' Copy/Paste some stuff
wbLatest.Worksheets(1).Range("A:A").Copy wbMaster.Worksheets("Data Sorter").Range("A1")
End Sub
Sub CallSubs()
Call NewestFile
Call SplitWords
End Sub