+ Reply to Thread
Results 1 to 5 of 5

Visual basic command button code help?

  1. #1
    Registered User
    Join Date
    10-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Visual basic command button code help?

    based on these tables
    http://oi40.tinypic.com/2n0ijw9.jpg

    top one is Customers table
    bottom one is Orders table

    what would the code be in a command button (userform) that will display all orders for a selected customer. This should include an option to view the result on a temporary worksheet, and also a “Print” button on the worksheet to preview the worksheet.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: Visual basic command button code help?

    As noted in your other post...
    Please do not upload a picture of your file...rather, upload a sample of your workbook, showing what data you are working with, a few samples of your expected outcome is (manually entered is ok) and how you arrived at that. (exclude sensitive info). Pictures are pretty much impossible to edit, and no-one wants to re-type your data for you Also, not all members can upload picture files (Company firewalls and stuff)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    04-29-2013
    Location
    Ontario, Canada
    MS-Off Ver
    MS Office 2010
    Posts
    80

    Re: Visual basic command button code help?

    Hi,

    Here is a possible solution:

    Insert a button in the sheet you need to filter and rename it as "Search" (Optional)

    Please Login or Register  to view this content.
    Insert a second button in the sheet you need to filter and rename it as "Print Preview" (Optional)

    Please Login or Register  to view this content.
    Attached is also a copy of a test spreadsheet.

    Hope this helps.

    Draconi

  4. #4
    Registered User
    Join Date
    10-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Visual basic command button code help?

    Quote Originally Posted by Draconi View Post
    Hi,

    Here is a possible solution:

    Insert a button in the sheet you need to filter and rename it as "Search" (Optional)

    Please Login or Register  to view this content.
    Insert a second button in the sheet you need to filter and rename it as "Print Preview" (Optional)

    Please Login or Register  to view this content.
    Attached is also a copy of a test spreadsheet.

    Hope this helps.

    Draconi
    thanks, except the command button Search & Print has to be on a userform (look at question2userform in vba)
    Assignment 2.xlsm
    Last edited by chicken9; 10-26-2013 at 09:56 PM.

  5. #5
    Registered User
    Join Date
    04-29-2013
    Location
    Ontario, Canada
    MS-Off Ver
    MS Office 2010
    Posts
    80

    Re: Visual basic command button code help?

    Hi,

    You can always use the same codes in the command buttons by double clicking on the button in VBA Developer. Just make sure that the macro is launched from the sheet you want to filter, or the code will have to change to reference the actual sheet as seen below:

    So you code would look like this.
    Please Login or Register  to view this content.
    It would be inefficient to copy all the filtered data to a new temp sheet to print preview, but also possible. Let me know.

    Draconi

+ 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. Is there a command in visual basic to move down one space, e.g. m.
    By Brent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2005, 09:05 PM
  2. [SOLVED] visual basic command to special paste a row of formulas into value
    By F.C in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-30-2005, 09:05 AM
  3. [SOLVED] [SOLVED] visual basic command identify a worksheet in a workbook
    By F.C in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2005, 10:05 PM
  4. Visual Basic: Setting up a button to switch on/off a picture
    By jeb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2005, 03:05 PM
  5. how to access a value from excel option button using visual basic?
    By henry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2005, 09:06 AM

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