I just can't seem to get this...I have a folder where the workbook is found...it looks for the files and opens them.
Sub getdata()
Dim MAPReport As Workbook
With Application.FileSearch
.NewSearch
.LookIn = ThisWorkbook.Path
.SearchSubFolders = False
.Filename = "mp*.htm"
.MatchTextExactly = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Workbooks.Open Filename:=.FoundFiles(i)
Set wkbk = ActiveWorkbook
No problem so far...
Then I run the following:
Windows("MAPReport").Activate
Dim LastRow As Long
With Worksheets("Summary")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("E38:E" & LastRow)
.Formula = "=IF(INDEX('Market '!C:C,MATCH(Summary!$C38,'Market '!A:A,0))="""",IF(ISNUMBER(MATCH($C38,mp1.htm!$A:$A,0)),INDEX(m1.htm!$E:$E,MATCH(E$2,mp1.htm!$D:$D,0)),""""),""Inactive"")"
.Value = .Value
End With
End With
Again No problem....
But what I really am trying to do is to have the code open the 1st mp*.html it sees run the calculation and place the value into Column E, then start back over with the search and find the next mp*.html it sees run the calculation again and place in the next column...so on and so forth.
The reasoning behind this is simple; the number of mp* files vary from 5 -15 and I don't want to have to add or delete code, defeats the purpose.
I have looked and read but I cannot seem to get this to work.
I really appreciate help on this!
Hans
Sub getdata()
Dim MAPReport As Workbook
With Application.FileSearch
.NewSearch
.LookIn = ThisWorkbook.Path
.SearchSubFolders = False
.Filename = "mp*.htm"
.MatchTextExactly = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Workbooks.Open Filename:=.FoundFiles(i)
Set wkbk = ActiveWorkbook
No problem so far...
Then I run the following:
Windows("MAPReport").Activate
Dim LastRow As Long
With Worksheets("Summary")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("E38:E" & LastRow)
.Formula = "=IF(INDEX('Market '!C:C,MATCH(Summary!$C38,'Market '!A:A,0))="""",IF(ISNUMBER(MATCH($C38,mp1.htm!$A:$A,0)),INDEX(m1.htm!$E:$E,MATCH(E$2,mp1.htm!$D:$D,0)),""""),""Inactive"")"
.Value = .Value
End With
End With
Again No problem....
But what I really am trying to do is to have the code open the 1st mp*.html it sees run the calculation and place the value into Column E, then start back over with the search and find the next mp*.html it sees run the calculation again and place in the next column...so on and so forth.
The reasoning behind this is simple; the number of mp* files vary from 5 -15 and I don't want to have to add or delete code, defeats the purpose.
I have looked and read but I cannot seem to get this to work.
I really appreciate help on this!
Hans