I have macro that runs OK when run by continually pressing F8 key and imports about 100 rows
However when I run with command button, it only imports 2 lines and then stops imemdiately without any error.
Sub SDrops()
Dim ws As Worksheet
Sheets("SunDps").Activate
Range("A3:G" & Application.Max(3, Range("A1000000").End(xlUp).Row)).ClearContents
empt = Cells(1, 4).Value
i = 3
For Each ws In ThisWorkbook.Worksheets
If ws.Name = "G" Or ws.Name = "H" Then
Lrw = ws.Range("F1000000").End(xlUp).Row
ws.Activate
For rs = 2 To Lrw
If Cells(rs, 3).Value = empt And Cells(rs, 7).Value <> "y" Then
Cells(rs, 3).EntireRow.Copy
Sheets("SunDps").Range("A" & i).PasteSpecial Paste:=xlPasteValues
i = i + 1
End If
Next rs
End If
Next ws
End Sub
Bookmarks