I want to setup two commands in one button

jlyn123

New Member
Joined
Jan 24, 2018
Messages
45
Office Version
  1. 2016
Hello,

I am trying to add a command to an existing button. Currently the button is export the data in excel into a PDF form and attaching to an email. What I would like to do with that same button is filter a column before the PDF attaches to the email. I need these two functions to happen at the same time or in the same button if possible.

Thanks for the help.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I am not a macro expert at all, but can't you just call the 2nd macro from the 1st macro? Then just link the 1st macro to the button and both would run because of that call.
 
Upvote 0
Hello,

I think this could work; however, I cant get my first macro to work. I would like to sort data in column A before the macro to pull the information in the spreadsheet is created into PDF format and attaching to an email. I don't know if by creating this email and PDF format it wont let me sort before? Or at least I cannot get it to work.

Thanks
 
Upvote 0
I'd say post your current code in here and see if someone can help. I dabble in code, but there are other people way more proficient at it than I am.
 
Upvote 0
This is the current sort code I have; however, I am not sure it is working. Nothing happens to the data and when its transferred into a PDF format and attached to an email the data doesn't sort either.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("A7:L100").Select
Selection.Sort Key1:=Range("A7:A100"), Order:=xDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

ThisWorkbook.Save
End If

Call Sub Click()

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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