Dim MyPath As String
Dim mybook As Workbook
Dim sfolder As String
Dim sMonth As String
Dim sYear As String
Dim R As Range
Dim sPeriod As String
With Sheets("DATA")
sMonth = .Range("B1").Value
sYear = .Range("A1").Value
End With
sPeriod = sYear & "-" & sMonth
sfolder = ThisWorkbook.Path
MyPath = "\\shares\groupdirs\0535\Portfolio Management\PM's " & sYear &
"\" & sPeriod & "\"
On Error GoTo CleanUp
Application.ScreenUpdating = False
For Each R In Range("AA3:AA33").Cells
If StrComp(R.Text, "yes", vbTextCompare) = 0 Then
Set mybook = Workbooks.Open(Filename:=MyPath & "\" & _
R.EntireRow.Cells(1, "A").Text)
Range("A1").Select
Selection.Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
On Error Resume Next
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Application.Trim(cell.Value)
Next cell
On Error GoTo 0
Columns("A:J").Select
With Selection
.VerticalAlignment = xlBottom
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A3").Select
End If
Next
Exit Sub
Im getting an excel message that says the file cannot be found. THe path
appears to be correct but there is no extension on the file. It should be
csv.
CleanUp:
Application.ScreenUpdating = True
End Sub