Hi!
I am trying to automate a painful process. I have a workbook that has a lot of sumifs for four countries. I will have to save workbook 4 times and value past certain ranges. I am trying to automate this process with following code.
I get an error at
Thanks
I am trying to automate a painful process. I have a workbook that has a lot of sumifs for four countries. I will have to save workbook 4 times and value past certain ranges. I am trying to automate this process with following code.
Code:
Sub Hardcode_v1()
Dim z As String
Dim i As Integer
Dim w As String
z = ActiveWorkbook.Name
For i = 1 To 4
Sheets("T1").Select
Range("A1").Value = i
If Not Application.CalculationState = xlDone Then
DoEvents
End If
savename = Application.GetSaveAsFilename(fileFilter:="Exel Files (*.xlsx), *.xlsx")
ActiveWorkbook.SaveCopyAs Filename:=savename
Sheets("Exposures transition matrix").Select
Range("c7:e17").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("P11").Select
Range("c12:o19").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:=savename, FileFormat:=51
Windows(z).Activate
Next i
End Sub
I get an error at
. What would be the problem?Windows(z).Activate
Thanks