VBA Code - Export as fixed format on active sheet

Nordicrx8

Board Regular
Joined
Dec 10, 2015
Messages
143
Office Version
  1. 365
Platform
  1. Windows
Hey all!

So the below code works great. Though sometimes I need to make a copy of the tab and export, though the button is still referencing the original tab. Is there any way I can make it reference the current tab it's in, rather than setting a fixed sheet?

thanks all!! :)


Sub Button1_Click()
Sheets("Daily Performance").Range("A1:d80").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try changing:
Code:
[COLOR=#333333]Sheets("[/COLOR][U][B]Daily Performance[/B][/U][COLOR=#333333]").Range("A1:d80").
to
[/COLOR]
Code:
[COLOR=#333333]ActiveSheet[/COLOR][COLOR=#333333].Range("A1:D80").[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top