Download presentation
Presentation is loading. Please wait.
Published byMaurice Newman Modified over 9 years ago
1
Macro’s Within excel
2
Most functionality can be driven from VBA VBA is the programming language that runs inside of excel. It uses visual basic as the core as it stands for visual basic application.
3
Printing with VBA Sub CreatePrint() Dim answer As Integer answer = MsgBox("Are you sure you want to print sheet?", vbYesNo + vbQuestion, "Print Sheet") If answer = vbYes Then ActiveSheet.PrintOut Else 'do nothing End If End Sub
4
Printing with VBA Sub CreatePrint() This part creates the sub-routine CreatePrint()
5
Printing with VBA Dim answer As Integer We are now defining answer as an integer.
6
Printing with VBA answer = MsgBox("Are you sure you want to print sheet?", vbYesNo + vbQuestion, "Print Sheet") We then are saying that the value of answer is equal to a response from a MsgBox (a pop-up dialog).
7
Printing with VBA If answer = vbYes Then ActiveSheet.PrintOut Else 'do nothing End If We now need to make sure the users meant to print and we can do so with their response and this if statement. It checks to see if the dialog response was yes and if it was, it prints the sheet. If it was no, it does nothing. The “’do nothing” is a comment, this is not actually processed it just helps us.
8
Printing with VBA End Sub Then we end the subroutine so the computer does not get confused between all the Macro’s code.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.