Originally Posted by
youngmcc
Hi
Please find another example.
This will only do it for ONLY .csv and .txt leaving all other data types in the cell and allows you to have fullstops in your filenames.
[vba]
Sub Test()
wsName = "Sheet1" 'Rename to appropriate Sheet
intColNum = 9 'Column I
For intRowCount = 1 To Sheets(wsName).Range("I1").CurrentRegion.Rows.Count
'Checks if the last 4 characters are CSV
If Right(Sheets(wsName).Cells(intRowCount, intColNum), 4) = ".csv" Then
avarCSVSplit = Split(Sheets(wsName).Cells(intRowCount, intColNum).Value, ".csv")
Sheets(wsName).Cells(intRowCount, intColNum) = avarCSVSplit(0)
Sheets(wsName).Cells(intRowCount, intColNum + 1) = ".csv"
'Checks if the last 4 characters are TEXT
ElseIf Right(Sheets(wsName).Cells(intRowCount, intColNum), 4) = ".txt" Then
avarTXTSplit = Split(Sheets(wsName).Cells(intRowCount, intColNum).Value, ".txt")
Sheets(wsName).Cells(intRowCount, intColNum) = avarTXTSplit(0)
Sheets(wsName).Cells(intRowCount, intColNum + 1) = ".txt"
Else
End If
Next intRowCount
End Sub
[/vba]