I am trying to make a macro that creates a PDF file of different specified ranges across different sheets. The current code im working with:
Sub Macro1()
Sheets("Administratief").Activate
ActiveSheet.Range("A1:F22").Select
Sheets("Spuiwater TID").Activate
ActiveSheet.Range("B4:F17").Select
Sheets(Array("Administratief", "Spuiwater TID")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
FormName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
The problem with this is that it uses the range of "A1:F22" in both sheets instead of using the range of B4:B17. Is there a way to fix this?
I'm not that familiar with VBA yet (getting to know the basics myself, just recently). But perhaps you could try to copy both ranges into a new sheet, then work out what you are doing with the data (putting them in an array and outputting into a PDF), and then delete the newly created sheet.
My way of 'learning' VBA is by basically recording a macro of whatever I'm doing, then putting them together in a way that I feel like it should work.
Hope that helps!