Hey all,
Simple question. How do I get excel to run the macro in the background?
In my code:
Sub Save()
Dim Rij As Long
Dim rapport As String
ThisWB = Application.ActiveWorkbook.Name
'Open file; if its open first save
On Error Resume Next
Application.DisplayAlerts = False
Workbooks("2").Save
Workbooks.Open ("2")
Application.DisplayAlerts = True
'copy files to wb 2
Rij = Application.WorksheetFunction.Match(Workbooks(ThisWB).Sheets(1).Range("B2").Value, Workbooks("2").Sheets(1).Range("B:B"), 0)
rapport = Left(ThisWB, 3)
If Workbooks(ThisWB).Sheets(1).Range("B2").Value <> rapport Then
MsgBox "Dont change this number"
Exit Sub
End If
If Workbooks(ThisWB).Sheets(1).Range("D2").Value <> Workbooks("2").Sheets(1).Range("G" & Rij).Value Then
Klant = "1"
End If
If Workbooks(ThisWB).Sheets(1).Range("F2").Value <> Workbooks("2").Sheets(1).Range("O" & Rij).Value Then
Door = "1"
End If
<Copy lots of values>
'If klant and/or door has changed. Create new file, otherwise just save
x = Workbooks(ThisWB).Sheets(1).Range("B2").Value
y = Workbooks("2").Sheets(1).Range("G" & Rij).Value
Z = Workbooks("2").Sheets(1).Range("O" & Rij).Value
If Klant = "1" Then
y = Workbooks(ThisWB).Sheets(1).Range("D2").Value
End If
If Door = "1" Then
Z = Workbooks(ThisWB).Sheets(1).Range("F2").Value
End If
NewName = x & " " & y & " " & Z & ".xls"
Application.DisplayAlerts = False
Workbooks(ThisWB).SaveAs Filename:="secret" & NewName
If Klant = "1" Or Door = "1" Then
Kill "secret" & ThisWB
End If
Application.DisplayAlerts = True
End Sub
I tried Application.ScreenUpdating = False, but without any results :/
The macro shows my -sarcasm- wonderful -/sarcasm- way of programming.. But although i'm not a programmer, I love doing this.
Bookmarks