View Single Post
 
Old 05-13-2019, 10:08 PM
FrancisSIP FrancisSIP is offline Windows 8 Office 2013
Novice
 
Join Date: Apr 2019
Posts: 5
FrancisSIP is on a distinguished road
Unhappy Macros were working but now aren't

So, the macros were working fine. However, a few hours later, when executing the macros, it runs but no result shows up as per before nor an error message.

I've searched online to find the source of the issue - whether it was a scripting problem or a software setting problem or bug. Hope I could get another helping hand!

The macros are below (I've edited them a bit).:

Code:
Sub FullBTExport()
'
' FullBTExport Macro
' Extracts all items with values from each schedule into one takeoff sheet for export.
    
    Range("2:100").Clear 'Erases all existing values from rows 1 to 100.

    Dim sourcesheet As Worksheet
    Dim i As Long, j As Long
    
    j = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 1
    
    For Each sourcesheet In ThisWorkbook.Sheets
        If sourcesheet.Name <> ActiveSheet.Name Then
            With sourcesheet
                For i = 6 To .Cells(Rows.Count, 3).End(xlUp).Row
                    If .Cells(i, 4) <> "" Then
                        ActiveSheet.Cells(j, 1).Value = .Cells(i, 1).Value
                        ActiveSheet.Cells(j, 2).Resize(, 6).Value = .Cells(i, 2).Resize(, 6).Value
                        j = j + 1
                    End If
                Next i
            End With
        End If
    Next sourcesheet
End Sub

Sub ExportCSV()
'
' ExportCSV Macro
'

Dim wbkExport As Workbook
Dim shtToExport As Worksheet

Set shtToExport = ThisWorkbook.Worksheets("BUILDER TREND ITEMS")     'Sheet to export as CSV
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = True                       'Possibly overwrite without asking
wbkExport.SaveAs Filename:="BT EXPORT" + " " + Format(Date, "dd-mm-yyyy"), FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=True

End Sub
Reply With Quote