Excel Tips and Tricks - Excel

advertisement
Excel Tips and Tricks
Jon Paul
Progressive System Solutions, Inc.
847-295-7179
jpaul@mba1980.hbs.edu
(Note- this was produced in 1997 for
the 97 version of Excel)
How Cold Was It?
So cold I know someone who slept with 16
sheets on their bed!
Just Open 1 Sheet!
•
•
•
•
Select Tools from Menu Bar
Select Options
Select General
Sheets in new workbook- change to 1
Moving Between Worksheets
• Find arrow buttons in lower left hand side
of screen
• Right mouse click on far right arrow button
• You now get list of sheets
• If large number of sheets, select more sheets
on the bottom
• Scroll down to find the sheet you want
• Click OK- away you go!
Moving or Copying a Worksheet
• Right mouse click on worksheet name
• Select move or copy
• Choose a workbook you want to send it to
– selects current workbook by default
• Select where in the workbook you want it
• Check Create a copy if you want to copy it
– Otherwise you could be moving and not be
expecting it!
Inserting or Deleting a Worksheet
• Right mouse click on any worksheet name
in your workbook
• Select Insert
• Double click on Worksheet to add a blank
worksheet to your workbook
• Can use same technique to add chart
• Deleting- follow same steps only select
Delete rather than Insert- be careful!
Driving With Half a Windshield
• Give yourself a full view of your worksheet
• One way to show the whole width- find
Zoom box- on toolbar and shrink
percentage
• Even better way–
–
–
–
highlight every column in your worksheet
go to Zoom box on toolbar
choose Selection
will automatically resize worksheet for you
Your Car Has More Than One
Window- So Can Your Worksheet
• Window menu- select New Window
• Gives you a second view of your current
workbook
• Second window is not sized
• If going back to one window, make sure you
are closing out the second
• Windows will be identified by :1 or :2
Do You Leave Your Doors
Unlocked?
No
But How About Your Spreadsheets
Is Your Neighborhood Safe?
Protect Your Work!
• Protecting a Worksheet
– First unlock cells you don’t want to protectsuch as input cells
– Then from Tools menu, select Protect
Worksheet
– Decide if you want Password protection- not
needed if just protecting against input errors
– Remember your password, or your work goes
to spreadsheet heaven
Add the Club to Your Workbook
• Protect Your Whole Workbook
–
–
–
–
–
In Tools menu, select Protection
Then select Protect WorkBook
Decide if you want password protection
Structure- prevents modifying structure
Windows- prevents opening, closing windows
You “Auto” Save This One!
• Ever have your computer crash
• Ever turned off your computer too quickly
And
• You forgot to save your file!
Your Insurance- AutoSave
• To enable AutoSave
–
–
–
–
Go to the Tools menu
Select Add-ins
The Add-in dialog box appears
Check AutoSave and click on OK
AutoSave Options
•
•
•
•
AutoSave is now in your Tools menu
Go to Tools and select AutoSave
The AutoSave dialog appears
Select your choices
– save automatically or prompt you
– how often to save
– open workbook or all workbooks
Painting Your House With a
Small Paintbrush?
•
•
•
•
•
•
Excel’s Paintbrush- like a power sprayer
Select range of cells with format you like
Click on the Paintbrush button
Click the cells you want to reformat
When you release, cells are reformatted
If you double click on Paintbrush button,
you can select non adjacient cells
Wrap That Text!
• Put long strings of text together neatly in
your columns without having to:
– Run over to the next column
– Make your column super wide
•
•
•
•
Select the cell or range (such as column)
Go to Format menu and select Cells
Go to Alignment Tab
Click in Wrap Text box
Does Your Data Make ‘Cents’?
Does anyone have $0.50 that I can borrow for
the pop machine?
No, but I might have 50 cents.
Custom Formats- Adding Cents
•
•
•
•
•
Select a cell you want to format
From the Format menu select Cells
Choose Number and then Custom
Select a format for the number portion
Go to the type box and the right hand side
– For the cent symbol, hold Alt key and type
0162- you see cent symbol on the screen
– For the cent name, type a space and cents
The Lawyers are Coming!
©
SM
TM
Make Your Lawyer Happy!
• Copyright– type ( c ) and enter
Your Lawyer Is Getting Happier!
• Supersript
–
–
–
–
–
type SM
highlight SM in formula bar
select format
check Superscript
cut down size of font
Now Your Lawyer Wants You to
Train Their Staff!
• Trademark- much easier
– type ( t m ) and enter
– no spaces inbetween
Come Together- Merging Text
• Concatenate- easier to use than pronounce
• Select cell where you want merged text
• Click on formula bar or select Insert menu
and then Function
• In the Function dialog, choose Text on the
left side and Concatenate on the right
Concatenating Tips
• Remember to include blank spaces
inbetween items
• Can refer to cells or put in text, but not at
same time
• Can copy concatenation formulas
• Can use text and number results
It’s Time to Concatenate
• Save retyping the same thing
• Allow for automatic updates
• Copying text where only part of the text is
the same
If Only the Cubs Could Replace
Their Lineup This Quick!
• Find & Replace
• Select Edit menu, then choose Replace
Replace Only What You Want To
• Highlight what you want to change
• Select Edit menu, then choose Replace
• Enter what you want to find and what you
want to replace it with
• Decide if you want to match case or entire
cell
Replacing- Finishing StepsSelective Replacement
• Choose option button to the right
• Find Next- when you only want to replace
in certain cases- you control the replacing
• Replace- to go ahead and replace after you
have found a cell you want
• Click Find Next to find the next case
• Click Replace for only those you want
• Click OK when done
Replacing- Finishing StepsAutomatic Process
• Use when you are sure you want to replace
every instance in the area you selected
• Activate by choosing Replace All button in
right side of dialog box
• Replaces everything in the area you choose
– cell, cell block, worksheet, workbook
• If you overdid it, go to the Edit menu and
select undo (or click Ctrl + Z)
Replacing- Some Ways to Use
• When something new is in the air!
• Copying workbook, worksheet or formulas
and using elsewhere
• Changing links, text or formulas
Help- I Can’t Get This Unstuck!
Are you using Superglue when regular Elmers
will do?
Pick Your ‘Glue’
Use the Paste Special Button
• To begin, same step as full blown copy
– Highlight area you want to copy
– Go to area you want to paste to
• Then select paste special one of two ways
– Right mouse click or
– Pull down from edit menu
• Choose the Paste Special Option
• Click on OK
Paste Special Options
•
•
•
•
•
•
•
Formulas
Values
Formats
All Except Borders
Transpose
Arithmetic Operation
Paste Link
They Have It In Rows, But I
Want It In Columns- Transposing
• Changing from rows to columns
• Changing from columns to rows
• When to use
– Change layout on new sheet
– Pull in information from a different layout (like
he has it in columns and I want it in rows!)
– Converting to database format
I Value Your InformationPaste Special- Value Option
• You want to capture the value, but:
– don’t need the formula
– can’t use the formula because it won’t work in
the new spot
I Like Your LayoutPaste Special- Format Option
• You have a layout you want to copy, but
don’t need the formulas or values
• Particularly good if dealing with a whole
block of cells
• Consider the paintbrush button as another
way to do this
• Can do with another paste special option
– first do the other option, then do format
I Like Your Formula- But Where
Did You Get That Layout?
• Use the Paste Special- Formula option to
just copy the formula
• Can then format any way you like
• Great to use when you already have your
format set up in your destination and don’t
want to override it
I Like Your Formula- But Don’t
Box Me In!
• Paste Special- All Except Borders
• Pastes formulas and formats except for the
borders
• Use where you like the formula and formats
but have a different setup for borders
Changing Data- We Won’t Tell
Your Boss How Easy It Is
•
•
•
•
Paste Special- Operation option
Fast way to change data automatically
Add, subtract, multiply or divide
Usually use with the value option in Paste
Special
How to Operate
• Put change in separate inactive cell
– such as 1.10 to multiply by 10%
• Copy that inactive cell
• Go to where you want to make changes
– this could be a whole range of cells
• Select paste special and the operation
– such as value and multiply
• Click on OK to finish
• Go back and erase the inactive cell
How Many Kids Do You Have?
We have an average size family
2.3 kids
Get A ‘Round’ to This
• Round functions for more meaningful
numbers
– 2 or 3 kids, not 2.3 kids
• Changes to whole number so next
calculation also makes sense
– at 10,000 per kid, cost is 20,000 or 30,000
• Round, Roundup or Rounddown
Round to Your Size
• Round- rounds up (5-9) or down (0-4),
depending on the digits being rounded
• Roundup- rounds up, away from zero
• Rounddown- rounds down, closer to zero
• How to do:
– = Round(calculation, decimal places)
– decimal places can be negative number
– substitute Roundup or Rounddown if wanted
How Do You Eat at a Buffet?
Do You Take Everything They Offer You?
Rumor Has It That I Do!
You Wouldn’t Build a House
Without These
• Ceiling– Round up to a nearest multiple (such as 10, 25)
• Floor– Same thing, only now you round down to a
nearest multiple
You Don’t Have to Sum
Everything Either
• SUMIF function- choose just what you
want to sum
• Enter your criteria
• Click on the cell where you want the sum
• Pull down the Function dialog box
• =SUMIF(Criteria Range,Criteria,Value
Range)
More on SUMIF
• Criteria Range- list describing what you
want to sum– such as rate plan chosen
• Criteria- which item from the list do you
want to sum
– such as which rate plan
• Value Range- range which holds the values
you want to sum
– such as monthly bills by rate plan
Okay- How Many Did You Take?
• COUNTIF- like SUMIF, but instead gives
you a count
• Not adding any values, so you only need the
Criteria Range and the Criteria
• =COUNTIF(Criteria Range, Criteria)
• = COUNTIF(A2:A20,Basic Rate Plan)
– counts number of times in A2:A20 that people
chose the Basic Rate Plan
How Much or How Little?
• MAXIMUM
– =MAX(Range)
– gives highest value in a range
• MINIMUM
– =MIN(Range)
– gives lowest value in a range
Who’s Number Two?You Might Care
• Get LARGE or SMALL
• =LARGE(Range,2)
– shows who is 2nd largest in the Range
• =SMALL(Range,3)
– shows who is 3rd smallest in the Range
We Even Like Average Things
• AVERAGE(Range)
– =AVERAGE(A1:A20) gives average in A1-A20
– Excludes blank cells; includes zeros
• MEDIAN(Range)
– Gives middle-most value in a range
• MODE(Range)
– Gives value that shows most often
Going Around in Circles?
•
•
•
•
The dreaded Circ message
Shows on bottom of screen
Keeps you from recalculating
Happens when two formulas refer to each
other
Break out of the ‘Circ’
• Find where the Circ is
– If it just says Circ, it is in some other worksheet
– If it says Circ F34 for example, you are there
– go to the cell it mentions
Fixing the Circ- Next
• Find the link
– use the auditing function if needed
• Check for cross referrals
– such as a=b and b=a
• Remember your last move before the Circ
The Circ Still Won’t Go Away!
or
I Have Grown a Whole Colony!
• How old is your backup of the file?
• Change one formula at a time to values
– when the Circ message goes away, that is the
formula you need to fix
• Delete sheets, columns or rows
– when the Circ message goes away, that is the
formula you need to fix
• Restore the copy and fix at that point
Make an Auditor Work for You!
• Select tools from the menu bar
• Pull down to auditing
• Select the direction you want to go
– dependents- where this cell links to
– precedents- what links into this cell
• Click on the arrow to go to that link
• When done, go back to the auditing menu to
remove the arrows
Other Auditing Tools
• Display formulas instead of values
– Tools menu- select Options
– Choose View tab
– Select formulas in Windows options
• Display information box for a cell
– Tools menu- select Options
– Choose View tab
– Select Information Box in display options
Ever See Someone Weigh
Themselves
One Limb at a Time?
Weighted Averages in One
Calculation
•
•
•
•
Use the sum function
Sum the first group, but dotn’t close yet
Multiply times the second group
Enter the closing parenthesis, but don’t
enter yet
• To enter the formula:
– Ctrl + Shift + Enter (all together)
• You will see brackets around the sum
Weighted Average Example
•
•
•
•
= sum(c4:c15*d4:d15)
to enter formula hit Ctrl + Shift + Enter
now looks like = sum{(c4:c15*d4:d15)}
if you just hit enter, you will get a Value?
error message
• to fix, click on the formula in the formula
bar and hit Ctrl + Shift + Enter
What’s Your Name?
Hi A3, I’m C4
What to Name
•
•
•
•
•
Columns
Rows
Ranges
Worksheets
Charts
Why Use Names?
Because It’s Easier To:
•
•
•
•
•
•
•
•
Remember names than references
Write formulas
Check and debug formulas
Copy formulas
Make links
Protect against broken links
Do search and replace
Update as needed
Which Formula Is Easier to
Check?
• A3 - A5
• Sales - Costs
How to Add Names- Name Box
• Using the Name box- left of Formula bar
– highlight the cell or range you want to name
– click in the box and enter the name (no spaces)
– hit enter (otherwise name does not get saved)
Adding Names- With Menu Bar
• Using the Menu- individually define
–
–
–
–
highlight the cell or range you want to name
in Insert menu, select Names
select Define Names
give it a name and click OK
• Using the Menu- group define
– highlight the range you want to name
– in Insert menu, select Names and Create Names
– select rows and/or columns and click OK
Use Names to Add Constants
• Example: WeekendFee = 9.95
• Suppose you have a value you will use over
and over again in a workbook
• Use names to set up that constant
• Makes sure you always use the same value
• If needs to be changed, can do all at once
• To set up constant, have to use Names menu
Referring to Names in Formulas
•
•
•
•
•
•
•
Go to cell and hit = or + to start formula
From Insert menu, choose Names and Paste
Select the Name and click OK
Can also select name by going to Name Box
Click on down arrow to pull up Name list
Select the Name and Enter
A third way- type in Name manually
Multiple Names in Formulas
• You can have multiple names in formulas
• To put in additional name:
–
–
–
–
Put in first name
Add the next part of your formula
Put in second name
Continue as needed
Show List of Names
•
•
•
•
•
•
You can paste a list of all names to a sheet
Insert new worksheet and call it Names
From Insert menu choose Names and Paste
From dialog box select Paste List
Expand size of column as needed
Note- new Names not automatically added
– Do paste link again as needed
Let’s Link Up
• Paste Special- Paste Link Option
• Use when you want to have an automatic
link to the original cell
• Only works with pasting all or pasting all
except borders
• Great for starting at source and copying to
the destination
More Than One Way to Link
• Can also link starting from the destination
cell:
–
–
–
–
Click on the destination cell
Enter “+” or “=“
Go to the source of the information
Hit enter to complete the link
Can You Name Another Link
•
•
•
•
•
•
•
Have you set up Names?
If so, you have an even better way to link
Get on the destination cell
Go to the Insert menu and select Names
Choose Paste option and select the Name
You now have a link to a Name range
Link needs to be in same relative position
Is Your Fence In Good Shape?Check Your Links
• In Edit menu, select Links
– If Links is greyed out, you have no links
• Can change source to different workbook
• Open source if you want to check it out
• If Update Source highlighted, may need to
click on Update Now to update
• If source already open, should automatically
update
Sherlock Holmes Wishes He Was
Around For This
• Solver- find the answer you are looking for
• Get the right answer right away, rather than
having to keep guessing until you get it
• Solve complex what-ifs very quickly
• Solver is an add-in- to install:
– In Tools menu, select Add-ins
– In Add-in dialog, click on Solver and then OK
Solver Steps
• In Tools menu, select Solver
– if Solver is not a choice, you need to add it in
• Target cell- where your target to solve is
• Equal to- specify value (or min or max)
• By changing cells- cells you want to change
to get target to desired value
• Can add constraints but not needed
• Click on Solve to let it run
Solver Result
• If Solver finds results, you get Solver
Results dialog box
– Get choice to keep choice or restore original
• Can also save choice as a scenario
• If there is not a logical choice, Solver will
come back and say it could not find one
– In that case, restore original solution
Can’t Make Up Your MindThen Don’t
With Scenario Manager
You can see it many ways
Scenario Manager
•
•
•
•
In Tools Menu, select Scenario Manager
Choose Add to add a scenario
Give scenario a name
Enter range of cells you want to change
– can do by clicking on each cell or range
– use comma inbetween multiples to separate
• Next you get dialog box to input values
Scenario Setup Tips
• Start with a scenario for the values you have
in place- such as Expected
• Percentages should go in at the decimal or
percent value- .05 or 5% rather than 5
• Can change multiple values in same
scenario
• Can go back and edit later
• Add scenario toolbar
Showing Scenarios
•
•
•
•
•
•
In Tool menu select Scenario Manager
You get the Scenario Manager dialog box
Highlight a scenario
Click on show to show the scenario
Can see results without closing dialog box
Even better way- use Scenario Manager
toolbox
Tools Tim Allen Would Love!
• Go to toolbar area- right click in open
section to the right
• Or in View menu, select Toolbars
• You get a toolbar menu- go to Customize
• Select the Utility category
• Click and hold on scenario box at right
• Drag to open area in toolbar section
• You are done- now click Close
Scenario SummaryShow Your Scenario Results
• In Tools menu, select Scenarios
• In Scenario Manager, choose Summary
• In next dialog box, select Scenario
Summary and click OK
• Your Scenario Summary is done in a
separate worksheet
If I Could Lookup My Remote
Control This Easy
• Do powerful lookups in groups of data
• Horizontal Lookup
– Lookup rows of data in column that you select
• Vertical Lookup
– Lookup columns of data in row that you select
Horizontal Lookup
• Enter lookup value in a cell
• Go to cell where you want the result
• Click on formula bar or Insert menu and
then Function to pull up Function box
• Select Hlookup
– Lookup value- cell where you have the value
– Table array- range of data you want to lookup
– Row index number- row number in the range of
data you are looking up
– Whether you want exact or approximate match
Vertical Lookup
• Enter lookup value in a cell
• Go to cell where you want the result
• Click on formula bar or Insert menu and
then Function to pull up Function box
• Select Vlookup
– Lookup value- cell where you have the value
– Table array- range of data you want to lookup
– Column index number- Column number in the
range of data you are looking up
– Whether you want exact or approximate match
When to Use Lookups- In Case
You Ever Need to Look This Up
• When the data in the table will change- just
change it in the table
• When your If statements are getting too
long
• When you need a good way to summarize
information
Lookup Pointers
• Have your data organized in a table
• Use a range name for the table
• Row and column numbers don’t change
when you copy a lookup formula– you need to edit these manually
• Make the input cell absolute for copying or
set it up as a range name also
When You Get to a Fork in the Road
Take it!
Your formulas can have forks to!
If Statements
• Get different results based on conditions
• If(condition, value if true, value if false)
• To do an If statement
–
–
–
–
–
–
Go to cell and type =If(
Type in condition- such as A1>B1
Type in value if condition is true- like +C3
Type in value if condition is false- like +C4
Type in ) and enter to finish
Here is a formula- =If(A1>B1,+C3,+C4)
Nests- Not Just For Birds
Use nesting to make powerful formulas!
Nesting- Here’s How
• Basic If statement
– =if(b3=c3,+c1,+d1)
• Nested If statement
– =if(b3=c3,+c1,if(b3=d3,+d1,+e1))
• A bigger nest
– =if(b3=c3,+c1,if(b3=d3,+d1,if(b3=e3,+e1,+f1)))
Picture This- Building Better Charts
• Store chart in separate sheet
• Need to reformat a line?
– double click on chart, then right mouse click
the line, bar, etc. you want to change
• Need to add or delete a section– double click on the Chart Wizard
– manually change the reference
• Can’t find a line you are looking for?
– hide the source of other lines to isolate this one
Help- My Chart Is In Mars
• You have gotten the ugly External
Reference is not valid message
– happens when you delete a section in a
worksheet that is still referred to in a chart
• It is there in the chart, but now just a dot
– Find the dot and click on it
– Reference should show in formula bar
– Delete the reference
Copying- Part of a Cell
•
•
•
•
•
•
•
Click on the cell
Go to the formula bar
Highlight the section you want
Right mouse click
Select copy
Go to where you want to paste
Select paste
Copying Part of a Cell- Use When:
• Copying part of a formula from one cell to
another
• Debugging part of a long formula
– copy pieces to individual cells to see the results
of the various parts of the formula
• Also can use this in reverse
– do long formulas in pieces in different cells to
test out first
– then piece together the formula
Calculating Alternatives One at a
Time?
Table that idea!
Instead, use data tables
Sample Data Table Layout
Cell 1 Name
Cell 2 Name
sample value
sample value
Result Cell
sample result
Formula Cell
Input Cell 1 Values
Sample Data Table Layout
Headers- Optional
Input Cell 2 Values
Data Table Results
Data Table Setup
•
•
•
•
•
Set up input cells 1 and 2 with sample value
Set up result cells with sample calculation
Block out rectangle for data table
Put formula in upper left corner of rectangle
Put input values in left column and top row
of rectangle
• Now ready for finishing steps
• Format formula cell same color as its
background so it doesn’t show
Data Tables- the Finish
• Highlight the Data Table range
– should be rectangle that includes row and
column values; start in upper left corner
•
•
•
•
From Data menu, select Tables
Enter Row Input cell
Enter Column Input cell
You are done!
And You Thought Vegematic
Could Slice and Dice!
Slice and Dice Your Data
Make Your Data Dance
Check Out Pivot Tables
Go 3D and Beyond
Get Your Data Ready
•
•
•
•
Needs to be in a database format
Titles in the first row
Data in the other rows
Can use data imported from other files
Transfering Data to a Pivot Table
•
•
•
•
•
From Data menu, select Pivot Table
The Pivot Table Wizard appears
Choose your source- usually Excel database
Select the database range- include titles
Next drag field buttons to where you want
that data in the pivot table (more on this)
• Finish- create pivot table name
Pivot Table Field Buttons Options
• Page- show data one “page” at at time on
the screen- such as one MTA, then another
• Rows and Columns- just as you think it is
• Data- the data in the middle
– remember, best if it is data (this is easy to
forget)
Explore Pivot Table Power!
• Move your field buttons around- like
looking in a cube from a different angle
– in and out of page view
– from rows to columns
– different order of fields
Here’s What One Looks Like
Date
(All)
Sum of Amount
MTA
AcctType Referral
Colorado Oregon
Wisconsin Grand Total
1 Year
Advertising
2096
500
435
3031
Direct Sale
14231
3442
1100
18773
1 Year Total
16327
3942
1535
21804
2 Year
Advertising
422
0
1496
1918
Direct Sale
6467
5500
1763
13730
2 Year Total
6889
5500
3259
15648
IRA
Advertising
364
0
920
1284
Direct Sale
270
100
426
796
IRA Total
634
100
1346
2080
Monthly
Advertising
650
1298
315
2263
Direct Sale
7941
2151
7986
18078
Monthly Total
8591
3449
8301
20341
Grand Total
32441
12991
14441
59873
Other Pivoting Tips
• When you refresh data you lose formatsconsider a macro to restore the formats
• You can do other things with the dataaverages, counts, maximums, minimums
• Can show same field twice– such as a sum and an average
• Consider different pivot tables for favorite
views
Calculations- Just For You
• You can build custom calculations
• Great for repeat calculations that you will
use in different workbooks or worksheets
• Great for changing a factor (such as
commissions) all at once
• Gets automatically added to the User
Defined function list
• Call up the calculation from the Function
Wizard just like built-in Excel functions
Calculation Example
Revenues
Min
1,000
2,500
5,000
10,000
20,000
Max
999
2,499
4,999
9,999
19,999
Rate
0%
4%
7%
10%
13%
15%
Calculation Function
• Function Commission2(Revenue)
•
Select Case Revenue
•
Case 0 To 999.99: Commission2 = 0
•
Case 1000# To 2499.99: Commission2 = 0.04
•
Case 2500# To 4999.99: Commission2 = 0.07
•
Case 5000# To 9999.99: Commission2 = 0.1
•
Case 10000# To 19999.99: Commission2 = 0.13
•
Case Is > 19999.99: Commission2 = 0.15
•
End Select
• End Function
Calculating the Commission
Enter Revenues
Commission Rate
Commission Amount
15,000
13%
1,950
Elephants Can’t Fly, But Your
Printer Can
• Use macros to automate your page setups
and printing
• Use buttons to set up print routines you can
easily go back to
Printing Macros- Setup
• In Tools menu, select Record Macro
• Then select Record New Macro
• Give macro a name (like Print (and sheet))
– can’t have space (so Print_Solver is OK)
• Select options and assign it to the menu if
you want it on the menu
• Select OK to start recording
Print Macro- Recording
• Go to sheet you want to print
– If already on the sheet when you set up macro,
then move to another sheet and back
• Click on the print button
• Then stop recording- click on the black box
• You are done with the macro
Check Out the Print Macro
• ' Print_Solver Macro
• ' Macro recorded 4/8/97 by Preferred Customer
• '
• Sub Print_Solver()
•
Sheets("Solver").Select
•
ActiveWindow.SelectedSheets.PrintOut Copies:=1
• End Sub
Make More Print Macros
• Go to the sheet where the print macro is
located (name it Print Macros)
• Highlight and copy Print_Solver
• Go below Print_Solver and paste
• Highlight the new macro
• Change Solver in new macro to Scenarios
• You now have your second print macro!
As Jay Leno Said- We’ll Make
More- Here’s a Faster Way
•
•
•
•
•
Code a macro directly- here’s how
Go below Print_Scenarios
Enter two spaces
Start with ‘ (apostrophe) for comment
Finish the comment line
– ‘ Print_Sumif Macro
• Enter another space- see next chart
Set Up Your Coding
• Now you are ready for the code
• Enter Sub and Macro name in first code line
– Sub Print_Sumif
•
•
•
•
Hit enter to finish this line
Hit enter again for a blank line
Next enter End Sub
Now we will go and enter the body
Finish Your Coding
• Go back to the blank space inbetween the
Sub and End Sub line- this is where we will
put the code
• Indent and then enter:
– Sheets(“Sumif”).Select
• Enter to finish that line; on next line enter:
– ActiveWindow.SelectedSheets.PrintOut Copies:=1
• That’s it- you finished!
Test Your Print Macro
• You can test your macro while still in the
Print Macro sheet
• Keep your cursor in the body of the
Print_Sumif macro
• Then click on the green arrow in the toolbar
above
• Your macro is running!
Summary- Macro Parts
•
•
•
•
Introductory Comments
Sub- starts the macro
Body of the macro
End Sub- ends the macro
Tying the Macros Together
•
•
•
•
Macros can also run other macros
First, manually set up another macro
Name this macro Print_All
In the body add names of other print macros
– Print_Solver
– Print_Scenarios
– Print_Sumif
• This macro will run all 3 at the same time
That’s Fine But I Don’t Like the Page
• One of the most cumbersome things in
Excel can be setting up pages
• Updating page setups isn’t much more fun
• Macros to the rescue here too!
Setup the Print Setup Macro
• Select a sheet you want to setup
• Set up recording a macro like before
–
–
–
–
Tools menu, Record Macro
Select Record New Macro
Give macro a name- call it Print_Setup
Click OK to start recording the macro
Record the Print Setup Macro
•
•
•
•
•
You are now recording the macro
Go to the File menu- select Print Setup
Make the print setup choices you want
Click on OK to close print setup
Click black recorder button to stop
recording macro
Using the Print Setup Macro
• If settings you want are already same as the
macro, just go ahead and run the macro
• If not, go to Macro sheet with Print_Setup
• Edit any setups you want to do differently
on another sheet
• Go to the sheet where you want to change
the print setup
• Run the macro
You Wouldn’t Dress Without
Buttons
• Use buttons for quick access to your macros
• Ways to use:
– For different print versions of the same sheet
– On a print index worksheet to choose which
sheets to print
Using Buttons
•
•
•
•
•
•
•
•
Locate a sheet for the buttons (Print Index)
Right click in toolbar area and select Forms
Click the Button button (sorry, had to say it)
Go to the spot where you want the button
Click and draw the button in
You can assign a macro; click OK to finish
Right click on the button to rename it
Add label next to button if you like
Adding More Buttons
• Repeat previous steps or
• Copy current button
– right mouse click and select copy
• Paste the button to the new spot
• Rename the new button
• Right mouse click new button and choose
Assign Macro
• Assign macro that belongs to new button
Waiter- It’s Not on the Menu
•
•
•
•
•
•
•
•
Another option to buttons
Put it on the menu
In Tools, select Macro
Click on the macro and then Options
Check the box, Assign to Menu Item
Add a name for the menu bar (spaces okay)
Click OK
It’s now on the bottom of the Tools menu
Closing Ideas
• Use Those Names!
• Keep Values in Separate Cells– don’t bury them in formulas
• Build Formulas in Pieces
• Split Your Work Into Separate Sheets or
Workbooks
– don’t overload a sheet or workbook
• Keep Learning and Experiment
Congratulations
You’re Ready to Excel!
Jon Paul
Progressive System Solutions, Inc.
847-295-7179
jpaul@mba1980.hbs.edu
Download