+ Reply to Thread
Results 1 to 7 of 7

Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

  1. #1
    Registered User
    Join Date
    04-22-2013
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    4

    Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

    Hi there,
    I am new to VBA/macros, but understand that the capabilities of it are near endless.

    I am trying to achieve a Production Schedule that I can email to contractors on a weekly basis - without the need to manually (and laboriously) cut&paste key data.

    I have scoured the web for any previously designed solutions for excel and haven't been able to find one that suits my application. Hopefully, someone can help me out...

    Attached is a sample workbook. Sheet1 shows the desired result of what I wish to achieve. Sheet2 onwards is the data to search.

    I require a BUTTON on Sheet1 that I can activate to populate the production schedule. This needs to search the entire workbook for cell A1="In Production" (note: cell A1 is a dropdown); if true, it will then copy Row4 to the next available row+1 on Sheet1. If A1="Complete" no action is taken and the search continues through the workbook. When the search/import is complete, I would like Sheet1 to be saved as a PDF named "Production Schedule_dd-mm-yy" (dd-mm-yy being the current day).

    From my research, I found that it would get VERY complex if I wish Sheet1 to auto update when I change any cell A1 value. So, I propose that when producing the weekly schedule: I will update all necessary cell A1s; then delete the previous week's "imported" data from Sheet1 (eg Row3 onwards); and then click the BUTTON to gather the data again (maybe the delete action could be included as an initial process of the BUTTON?).

    Additional info:
    • PDF to fit all columns on A4 landscape
    • I estimate the imports rows on Sheet1 will not exceed 100 rows (eg no more than 100 worksheets)
    • I will rename Sheet1 To Production Schedule
    • Each Sheet Name will be in "Purchase Order No.-Product No." format
    • Sheets will not be deleted when set to "Complete"
    • When a new sheet is inserted, it will be from a custom template (obviously with same key data layout)


    Thanks for your time all...


    Cheers

    TEST Production Schedule1.xlsx

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Post Re: Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

    I trust you can place a button from "Form Control" and assign a macro.

    Here's a code to get you started. Modify it to suit your needs:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-22-2013
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

    Thanks for your efforts jewelsharma!- it is very close to what I desire!

    There are some scenarios that are beyond my skills to resolve - would you be able to help me a little further?

    The scenarios:
    • when a row is copied to Sheet1; cells H4, I4, and J4 are copied with their original formula and lose their reference (therefore they display zero). Can the whole row be copied just as text?
    • when the macro reaches the first "Complete" it stops and does not continue searching the remaining sheets in the workbook for "In Production" (refer attached Production Schedule PDF - no info was copied from Sheet5 which was "In Production"). Can this be resolved?
    • I attempted to change the sheetnames to the correlating "PURCHASE ORDER No."-this creates an error-refer attached (the sheetname is important for me to find an individual order at a glance)-Can this be resolved?
    • the PDF saving function and the date input are FANTASTIC! I'm very pleased with the ease of use!


    Thanks for your help...


    Trentineer
    Production Schedule_03-04-14.pdf
    Error message.pdf

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Post Re: Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

    Happy to help.

    Please rename worksheets as:
    • "PURCHASE ORDER No.1"
    • "PURCHASE ORDER No.2"
    • .... and so on. The names are case-sensitive. The spaces et.al. should be exactly as above.
    • Do not rename "Sheet1"

    Here's the modified code:
    Please Login or Register  to view this content.
    Trust this meets your needs. Please mark the thread as [SOLVED].

    Regards,
    Jewel

  5. #5
    Registered User
    Join Date
    04-22-2013
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

    Hi Jewel,

    Thank you so much!-it works a treat!

    My next step is a TOC with hyperlinks to each sheet in column1 and the corresponding unique purchase order numbers in column2...


    Cheers,
    Trent

  6. #6
    Registered User
    Join Date
    04-22-2013
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

    Hi Jewel,

    I have inserted an INDEX into the workbook to help with navigating to a specific Purchase Order No.

    This change has created an error (refer attached).

    The Production Schedule is still created, but the save as PDF file function has been lost.


    Could you please lend some assistance?


    -error message and workbook sample is attached


    PS: I am going to post a separate question regarding importing some additional info (column B, C, & D) into the INDEX.



    Thanks,
    Trent

    TEST Production Schedule2-WITH BUTTON.xlsm
    Error message.pdf

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Arrow Re: Button to search workbook for A1="x", if true, then copy Row4 to Sheet1

    Hi Trentineer,
    Mate, ideally, one should have raised this query via a separate thread. My understand is that you are building your workbook bit-by-bit, and hence this follow-up query. I'm happy to note that you will raise separate threads for importing info into your Index sheet, wherein you may provide a link for this thread to link them and provide a trail to follow. (I think I've already overdone the lecturing part. Forgive me )

    Now, with regards to the new error, it happens because of the new sheet (i.e "INDEX") in this workbook is not named as "PO(some number). Explanation: When the FOR-NEXT loop in the code runs, and it looks for a sheet name "PO(some number)", which it doesn't find & hence the error.

    To fix it, please replace the FOR-NEXT loop part of the code with the following:
    Please Login or Register  to view this content.
    Let me know if anything!
    Last edited by jewelsharma; 04-16-2014 at 09:16 PM. Reason: The OP has already marked the thread as [SOLVED]

+ 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. Create a Command Button to "Save As" and "Close" an Excel Workbook
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-26-2013, 05:38 PM
  2. Replies: 6
    Last Post: 03-14-2012, 01:01 AM
  3. search and copy values from workbook "B" depending on values in workbook "A"
    By jmarkb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2011, 03:39 PM
  4. Macro to search a "database" in a different workbook and copy whole page when matched
    By TheNewGuy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-24-2009, 11:08 AM
  5. Replies: 2
    Last Post: 05-05-2008, 04:51 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