I am trying to create a macro that will copy the first row A8:V8 from the [Summary] tab to the [Annual Statement] tab, recalculate, and then save [Annual Statement] tab as pdf with the name of cell A8 from [Summary] tab. This code works as-is for the first row A8:V8. I'd like to make this macro more dynamic and loop to the next row down, A9:V9, and then repeat the same process of copying the values to the [Annual Statement] tab and saving as pdf and then repeat entire process again for the next row down.
Here is the code –
Sub AnnualStatements()
Dim RI As Workbook
Set RI = ThisWorkbook
Dim strpath As String
Dim strName As String
Dim strFile As String
Dim strPathFile As String
**'Copies over policy information from summary to annual statement tab**
Worksheets("Summary").Range("A8:V8").Copy Worksheets("Annual Statement").Range("O3")
Calculate
**'Below is what I want to change the above line to but it isn't working**
For i = 1 to 10
Worksheets("Summary").Range(Cells(7+i, 1), Cells(7+i, 21)).Copy Worksheets("Annual Statement").Range("O3")
Calculate
**Creates location and path to save annual statement pdf file to**
strpath = "C:Users\Documents"
strName = Sheets("Summary").Range("A8")
**‘strName = Sheets(“Summary”).Cells(7+i,1)** '' tried changing to this but not working
strFile = strName & "_Annual Statement" & ".pdf"
strPathFile = strpath & strFile
**Saves as pdf**
Worksheets("Annual Statement").ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=strPathFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
**'Next i 'tried adding this but not working**
End Sub