Hello All,
I am trying to fix the following macro which I am trying to execute in MAC. It works/loops for sometime and then excel gets closed. My code below:
I am trying to fix the following macro which I am trying to execute in MAC. It works/loops for sometime and then excel gets closed. My code below:
Code:
Set wb = ActiveWorkbook
Set ws = Sheet1
a = Sheet4.Cells(Rows.Count, "A").End(xlUp).Row
If a > 1 Then
For b = 2 To a
c = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row + 1
Workbooks.Open (Sheet4.Cells(b, "A").Value)
Set wbb = ActiveWorkbook
Set sh = wbb.ActiveSheet
bb = sh.Cells(Rows.Count, "A").End(xlUp).Row
wb.Activate
ws.Select
Range(Cells(c, 2), Cells(c + bb - 1, 4)).Value = Workbooks(wbb.Name).Worksheets(sh.Name).Range("A1:C" & bb).Value
wbb.Close savechanges:=False
Set sh = Nothing
Set wbb = Nothing
d = Sheet1.Cells(Rows.Count, "B").End(xlUp).Row
Sheet1.Range(Cells(c, "A"), Cells(d, "A")) = Replace(Sheet4.Cells(b, "B").Value, ".txt", "")
Next
End If
Application.CutCopyMode = False
ActiveWorkbook.Save
Last edited: