I tried to use parts of two working macro's to make a new one for a repetitive task. When I run the macro, all it does is close the active workbook. What have I done wrong, What needs to change?
++++++++ I USED THIS ++++++++
++++++++ AND THIS ++++++++
++++++++ TO MAKE THIS ++++++++
I just needs to save as the value of R4, then change the formulas to the next row down, ($2 to $3), then save as value of R4, chance $3 to $4, etc.
++++++++ I USED THIS ++++++++
Code:
Sub Make_Batch_Forms()
Dim lngRowRef As Long, lngFileNr As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Sheets("RFMD Form").Rows("4:11")
For lngRowRef = 2 To 102
lngFileNr = lngRowRef + 248
ActiveWorkbook.SaveAs Filename:="2011-" & lngFileNr & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
.Replace What:="$" & lngRowRef, Replacement:="$" & lngRowRef + 1, _
LookAt:=xlPart
Next lngRowRef
End With
ActiveWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
End Sub
++++++++ AND THIS ++++++++
Code:
Sub Example3_Loop()
'
' Example3_Loop
'
StartVal = 1
NumToFill = 12
ActiveCell.Value = StartVal
For Cnt = 0 To NumToFill - 1
ActiveCell.Offset(Cnt, 0).Value = StartVal + Cnt
Next Cnt
'
End Sub
++++++++ TO MAKE THIS ++++++++
Code:
Sub Make_Batch_Forms()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Sheets("PLQ Form").Rows("4:59")
StartVal = 2
EndVal = 26
For Cnt = 0 To NumToFill - 1
PQname = Range("R4").Value
ActiveWorkbook.SaveAs Filename:=PQname & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
.Replace What:="$" & StartVal, Replacement:="$" & StartVal + Cnt, _
LookAt:=xlPart
Next Cnt
End With
ActiveWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
End Sub
I just needs to save as the value of R4, then change the formulas to the next row down, ($2 to $3), then save as value of R4, chance $3 to $4, etc.