Wednesday, March 30, 2016

Fast Solution to Error: A macro to call up other macro's based on a value in a cell.

A macro to call up other macro's based on a value in a cell.

I have nine buttons that call up a macro which selects and prints an area of cells.
Having nine buttons takes up alot of room on the spreadshhet and i would like just one.
I have a formula which equates to a number depending on the area size i need to print.
I would like a macro which looks up this value and then prints the correct area of cells.
i.e, if the formula returns 1, then print area B1:C2 (Macro1)
if the formula returns 2, then print area B1:D3 (Macro2)
this will repeat 9 times for different areas.
Any help on this matter would be greatly appreciated.
Ta, Jonno

Solutions to the Problem A macro to call up other macro's based on a value in a cell.

Download Error Fixer for Free Now

Hi,
This assumes your formula is in F1 so change that to suit and set up the correct print ranges for each case
Private Sub CommandButton1_Click()
ActiveSheet.PageSetup.PrintArea = ""
Select Case Range("F1").Value
                Case Is = 1
                    r = "$A$1:$D$12"
                Case Is = 2
                    r = "$A$1:$D$13"
                Case Is = 3
                    r = "$A$1:$D$14"
                Case Is = 4
                    r = "$A$1:$D$15"
                Case Is = 5
                   r = "$A$1:$D$16"
                Case Is = 6
                    r = "$A$1:$D$17"
                Case Is = 7
                    r = "$A$1:$D$18"
                Case Is = 8
                    r = "$A$1:$D$19"
                Case Is = 9
                    r = "$A$1:$D$20"
                Case Else
                    Exit Sub
            End Select
    ActiveSheet.PageSetup.PrintArea = r
   ActiveWindow.SelectedSheets.PrintOut Copies:=1
End Sub

If this post answers your question, please mark it as the Answer.
Mike H

Check Windows System Requirements

This error can be due to some configuration requirements for you system. If your PC hardware is not up to par, then make sure you upgrade where necessary before continuing:

Microsoft Windows Requirements :

  • 1 gigahertz (GHz) or faster 32-bit (x86) or 64-bit (x64) processor
  • 16 GB available hard disk space (32-bit) or 20 GB (64-bit)

Recommended Method to Repair the Problem: A macro to call up other macro's based on a value in a cell.:

How to Fix A macro to call up other macro's based on a value in a cell. with SmartPCFixer?

1. Download Error Fixer. Install it on your system.

2. After the scan is finished, you can see the errors and problems which need to be repaired.

3. The Fixing part is finished, the speed of your computer will be much higher than before and the errors have been removed.


Related: [Solved] Applications have stopped working with SP1 on Windows 7!,[Solved] I can't find auto complete text in word 2007,[Solution] I need to keep reinstalling eHome Infrared Transceiver driver everytime my computer shuts down.,How to Resolve - system restore not working windows 7?,Unable to open embedded word file on the intranet. [Solved],Solution to Error: Error: "0x81000032 make sure the C: drive is online and set to NTFS" when trying to backup to external hard drive.
,Troubleshoot:External Hard Drive not listed in Windows 7 backup wizard Error
,I'm always being signed off so annoying Tech Support
,Solution to Problem: Impossible to use Internet Explorer! I keep getting the same error message every time i try to use IE.
,Solution to Problem: Referencing data in another file
,[Anwsered] Thinkpad 8611 Boot,How to Resolve - Svchost Helper?,Fast Solution to Problem: L30 101 Driver Windows 7,Troubleshooter of Error: Io Device,How to Fix Error - Dell Laptop Code 39?
Read More: Ad-Hoc Networking Problems in Windows 8.1 [Anwsered],How Can I Fix - Active Cell Appearance?,Accidentally delete system restore schedule on task scheduler,Fast Solution to Error: A timeout occurred while receiving windows live mail with the server,Fast Solution to Error: A message box appears under a certain condition,Cannot delete empty file icon on desktop...,Cannot download flashplayer,can't get the CIA review progrom install which is an older version,Cannot access one website-DNS server not responding.,Can't Receive or Send Vista Windows Mail - Router stopped recognizing DSL connection & wants to dial up

No comments:

Post a Comment