Combine 3 Macros into one

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello,

I am hoping I can combine three macros into one. The macros are to save data after it is entered in to database (User Form) , the second will re-sequence the database in ascending order, and lastly since these are all fed into a Pivot Table - the last macro is the refresh. This will all be done when the Command Button "Save". If I could only get two then it would definitely be the first two. I cannot have people going to the database and trying to manually re-sequence them.


VBA Code:
Private Sub CMDSAVE_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want to save Mission?", vbYesNo + vbInformation, "Confirmation")
If msgValue = vbNo Then Exit Sub
Call Submit
Call RESET
End Sub

VBA Code:
Private Sub CMDSAVE_Click()
Dim xlSort As XlSortOrder
Dim LastRow As Long
With Sheets("ACTIVITY")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1") = "Date"
.Columns("A:F").Sort key1:=.Range("A2"), order1:=xlAscending, Header:=xlYes
End With
End Sub

VBA Code:
Sub RefreshPivotsOnly()
  Dim tblPivot As PivotTable
  For Each tblPivot In ActiveWorkbook.PivotTables
     tblPivot.RefreshTable
  Next tblPivot
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi,
Why not use the CALL statement to run those three procedures in sequence, as you have already done in your code? Is there any problem with that?
 
Upvote 0
Hi,
Why not use the CALL statement to run those three procedures in sequence, as you have already done in your code? Is there any problem with that?
Hi thank you, I'm quite familiar with what you're speaking about. I guess it is because it is on a User Form triggered by the “CmdSave” button. For now everything gets put in ascending order by date. I meant to say in descending (most recent dates on top) in my original post. Since the first two are “Private Sub” it may be easier to get a least two in one under the same button. The other one is the refresh button. I can accept one extra button. I'm just trying to prevent people from going to "Data" to refresh the Pivot Table.

Yes this is the User Form which places everything in a Database then ultimately a Pivot table. It's quite beautiful really, just trying to add the cherry on top.
 
Upvote 0
Hi,
Why not use the CALL statement to run those three procedures in sequence, as you have already done in your code? Is there any problem with tha
Hi,
Why not use the CALL statement to run those three procedures in sequence, as you have already done in your code? Is there any problem with that?
Not sure if you were still looking into this. I found someything that I can live with, while I did combine formulas I got what I needed another way. Thank you so much for your consideration.
 
Upvote 0
I couldn't help you out but glad it seems that you could solve your problem.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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