Hi,
I'm drafting a simple VBA code, I would like to use it to cycle through different options and print a set of tables corresponding to combinations of different options. I'm using For To commands and counts to select different options. Unfortunately, I keep on getting 1004 error. I'm wondering if someone could help me with this small assignment? My code looks like follows:
Private Sub PrintAllTables_Click()
'
' PrintAllTables Macro
' Prints all tables for the workbook.
'
' Keyboard Shortcut: Ctrl+Shift+T
'
Dim count As Integer
Dim year(2) As String
Dim service(2) As String
Dim countB As Integer
Dim countC As Integer
year(1) = "2010"
year(2) = "2011"
service(1) = "People Services"
service(2) = "Other Services"
For count = 1 To 4
count_str = CStr(count)
Range("family_number").Value = count
Application.Run "Update"
For countB = 1 To 2
Range("year_selection").Value = year(countB)
Application.Run "Update"
For countC = 1 To 2
Range("service_area").Value = service(countC)
Application.Run "Update"
Next
Application.Run "Update"
Next
Next
MsgBox "PDFs were generated successfully.", vbInformation + vbOKOnly, "Macro finished"
End Sub
Bookmarks