+ Reply to Thread
Results 1 to 8 of 8

Using a drop down list to select print range

  1. #1
    Registered User
    Join Date
    02-25-2014
    Location
    Durban South Africa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Red face Using a drop down list to select print range

    Good Day, I have a macro to print named ranges which are entered in a message box. I would like to use a drop down list to select the ranges from so as to eliminate errors due to typo errors. I know how to populate and validate the range names for the drop down list but do not know how to incorporate this into my macro for printing?
    The named ranges are names of months - Mar to Dec each range consisting of 20 values. The drop down list is populated with the names of the months and I want to choose a range to print from the drop down list.

    The first part of the macro is as follows:-

    Option Explicit

    Sub PrintResults()
    '
    ' Keyboard Shortcut: Ctrl+Shift+Q

    'check functionality status

    Dim PrintRange As String
    Dim screenUpdateState

    screenUpdateState = Application.ScreenUpdating

    Application.ScreenUpdating = False 'turn off screen updating to stop flicker & increase speed

    ActiveSheet.Unprotect Password:="1234"

    PrintRange = InputBox("range to print") 'Input box asks for named range then prints the range you entered

    Application.PrintCommunication = False

    With ActiveSheet.PageSetup
    .PrintTitleRows = "$1:$4"
    .PrintTitleColumns = ""

    End With

    Etc, etc

    I would be most grateful for some help here.

    Regards

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Using a drop down list to select print range

    Perhaps something like this
    3 named ranges created
    RefersTo for each name reflects required print range

    Test in attached file by selecting a value from dropdown in M1 and clicking on Print button

    SelectPrintRange.jpg

    Print Button returns message box detailing selected print range

    SelectPrintRange2.jpg


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kev_; 03-28-2018 at 06:14 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    02-25-2014
    Location
    Durban South Africa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Using a drop down list to select print range

    Thank you Kev I will try working on that, and will come back to you if I get it right
    Much appreciated

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Using a drop down list to select print range

    There is more than one way to achieve what you want. I tend to aim for the simplest approach. But I do not know what else you have in mind and so my first suggestion may not necessarily be the best option for you

  5. #5
    Registered User
    Join Date
    02-25-2014
    Location
    Durban South Africa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Using a drop down list to select print range

    Hi Kev, Yes what I had in mind is that only 1 macro is needed to print from the values in the drop down list. The drop down list is a list of named ranges ( MAR to DEC)each with a unique range. So I wanted the macro to be triggered by the value selected in the drop down list. Is that possible?

    So I have a Forms Button (Prints Months) on the same sheet as the ranges and so I would like that when the Button is pressed , the drop down list comes up and the selection can be made and that will trigger the macro to print range selected.

    My macro presently does the job with a Message box where the operator enters the month range and the macro prints the range.

    This is the present macro up to the page set up:

    Please Login or Register  to view this content.
    Thanks and regards
    Last edited by PatrickMinto; 03-29-2018 at 06:25 AM. Reason: To add code tags

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Using a drop down list to select print range

    Please add code tags etc to both your first and second posts

    This is Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between tags like this...
    [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE]
    .... makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then select code text and click the # icon at the top of your post window. More information about these and other tags can be found here

    thanks
    Last edited by kev_; 03-29-2018 at 05:04 AM.

  7. #7
    Registered User
    Join Date
    02-25-2014
    Location
    Durban South Africa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Using a drop down list to select print range

    Hi Kev,
    Thank you I have resolved my query and my code is working fine - the Print Button is using the values in the Drop down list, and I have dispensed with the Message box.
    Kind regards

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Using a drop down list to select print range

    Glad you are fixed up
    Please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto-Select From Drop Down List and Print Reports
    By thegloverfamily in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2016, 09:27 AM
  2. vba code to select all data in drop down and to take print
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2014, 05:16 PM
  3. Replies: 0
    Last Post: 04-22-2014, 11:03 PM
  4. Replies: 5
    Last Post: 04-11-2014, 03:13 PM
  5. [SOLVED] Select from drop down list to show another drop down list in a different cel
    By ExcelRanger in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2012, 04:27 PM
  6. How do I use one list drop down menu result to select another list?
    By steveinspain in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-02-2007, 02:59 PM
  7. Replies: 5
    Last Post: 10-27-2005, 01:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1