+ Reply to Thread
Results 1 to 7 of 7

A macro that will format data in another sheet, print it, and loop that process.

  1. #1
    Registered User
    Join Date
    06-05-2019
    Location
    Maryland
    MS-Off Ver
    i have no idea
    Posts
    5

    A macro that will format data in another sheet, print it, and loop that process.

    Excel Capture 3.PNGExcel capture 2.PNG

    I am working on a project that involves printing a large amount of "Part Tickets". Attached is a picture of the worksheet I am using. There is a macro that pulls this data from a dart query, and formats it together on that excel worksheet. I need to create a macro that, when ran, will run row by row down worksheet 1, pull the data from each row and put it as I have formatted in the other picture on worksheet 2, print that row of data in the format I have, then continue to go down the worksheet and essentially format and print all of the data in the worksheet.

    The goal here is to be able to select a range of dates from the dart query, and with the help of excel macros, auto print these "Part Tickets" for all parts needed in a selected date range. The tickets have a very specific size to them and are printed on a unique printer, which is why the format is important.

    This is my first post as I am just now learning about excel macros through this project. If anyone is able to help it would be very much appreciated.

    Thanks!
    Last edited by lancerfan55; 06-06-2019 at 02:05 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: A macro that will format data in another sheet, print it, and loop that process.

    I am not sure if your data is on a sheet with a filter active or if the data is in a named table (ListObject). The code below assumes a filtered sheet.
    Please Login or Register  to view this content.
    Note that the sheets are referred to by index number and require edititing to use actual sheet names in the code. eg. Sheets(1) edited as Sheets("Print").
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    06-05-2019
    Location
    Maryland
    MS-Off Ver
    i have no idea
    Posts
    5

    Re: A macro that will format data in another sheet, print it, and loop that process.

    The worksheets are just named sheet 1 and sheet 2, so I shouldn't have to make any edits, correct? Although I am unsure if the data is filtered or unfiltered (pretty new to all this).

    I ran the code you supplied a few times, and it did not generate the tickets to print. Although it seems to generate a Kutools box 25% of the time which asks me to highlight something and I am unsure of what it wants me to select.

    I was also wondering, If the code works, should the usual print screen pop up confirming print options, or will it just use my default printer and send it straight to printing? If possible, I would want it to generate the print screen to select a specific printer.
    Last edited by lancerfan55; 06-07-2019 at 09:21 AM.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: A macro that will format data in another sheet, print it, and loop that process.

    The worksheets are just named sheet 1 and sheet 2, so I shouldn't have to make any edits, correct?
    No, that is not correct. Sheets(1) is not necessarily Sheets("Sheet1") and same for Sheets(2). The index number is based on the sheet order of the sheet name tabs as they appear to the user from left to right, regardless of the names on the name tab. So you need to replace the index numbers with actual sheet names for the sheets that contain the data.

    I am not familiar with Kutools and have no idea why the code would produce such a display.

    If the code is installed in code module 1 (Not a sheet code module and not ThisWorkbook code module) and the worksheet references are correct and the data is not in a named table, then it should take the six cells from each row of sheet 2 and place them on sheet 1, cells B2:D3, to be printed. Whether you get a print preview or not will depend on your system settings.
    Last edited by JLGWhiz; 06-07-2019 at 11:36 AM.

  5. #5
    Registered User
    Join Date
    06-05-2019
    Location
    Maryland
    MS-Off Ver
    i have no idea
    Posts
    5

    Re: A macro that will format data in another sheet, print it, and loop that process.

    Set sh1 = Sheets("sheets1") 'Edit sheet name - print sheet
    Set sh2 = Sheets("sheets2") 'Edit sheet name - data sheet

    I edited these lines to say sheets1 and 2 as those are the names of each sheet respectively. I have tried about 10 different things with the Kutools box that generates. I am still struggling to get anything to print. Not sure if it is because of the kutools thing or something I am missing

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: A macro that will format data in another sheet, print it, and loop that process.

    As i said, I am not familiar with the Kutools addin. I have no idea how it is triggered, how it is used or how to avoid it. If the code is not working for you, then it means that the code cannot be applied to that worksheet with the data entered in the current manner and I cannot change the code to compensate for it without being able to understand exactly what we are working with. So I will just drop off this thread. Sorry I couldn't help.
    Regards, JLG

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: A macro that will format data in another sheet, print it, and loop that process.

    Administrative Note:

    Welcome to the forum.

    We would love to help you with your query; however, it has been brought to our attention the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    HTH
    Regards, Jeff

+ 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. Replies: 1
    Last Post: 11-15-2019, 02:57 AM
  2. vba loop macro to process different files and merge them in a single workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2017, 03:07 AM
  3. [SOLVED] Copy, Paste, Print data to a form & repeat process on next row.
    By Bikeman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-28-2016, 10:33 AM
  4. macro to loop through data sheet , fetch 8 rows at a time and put in new sheet
    By nyree in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2015, 01:46 AM
  5. MACRO that will process input files into the output format
    By drobinson782001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2013, 01:26 PM
  6. [SOLVED] Need to close opened workbook after copying sheet(3) and repeat process using loop.
    By Kammphoto in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2013, 10:55 AM
  7. Macro/Module running as background process, copy data from sheet to sheet
    By ctor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2009, 05:48 AM

Tags for this Thread

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