+ Reply to Thread
Results 1 to 11 of 11

Applying Predetermined Formatting/Logic to a Downloaded Table

  1. #1
    Registered User
    Join Date
    08-30-2022
    Location
    East Coast, USA
    MS-Off Ver
    365 MSO Version 2202
    Posts
    13

    Applying Predetermined Formatting/Logic to a Downloaded Table

    Every week I generate a report that has dates, names, and lead times (number of calendar days). The generated report is just a simple Excel table with headers and no other formatting. I want to create rules for each column through conditional formatting, however I don't want to have to re-write (or copy/paste) the rules to the new report...every week...that the report is downloaded.

    Is there a way to save my rules/logic/formatting ---> download the simple Excel table without formatting ---> re-format that Excel table to my pre-determined formatting/logic/rules?

    I will be doing this weekly, so I'm trying to minimize the amount of clicks required. Ideally, this done in an single Excel file that I upload the simple Excel table to, auto re-format, and Save As "Week of ___" every week.

    Thanks!
    Last edited by lemoncells; 12-04-2023 at 10:16 AM. Reason: Solved!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    You can:

    Have a preformatted template file with the desired formatting. Go to your table, and copy it. Go back to your template and Paste Formulas, which will paste all values and formulas but not affect the formatting.

    or

    Have a preformatted template file with the desired formatting. Go to the template and copy it. Go to your table, Paste Formats.

    This could also be automated as one click if you want to use VBA. To actually write the VBA we would need a file sample.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-30-2022
    Location
    East Coast, USA
    MS-Off Ver
    365 MSO Version 2202
    Posts
    13

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    Thank you.

    Is there a cooler way of doing this? Like being able to save my formatting, download the table, click something/somewhere in the Ribbon, and apply the formatting to the downloaded table?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    There is no one-click solution built-in for what you want to do.

    Excel has cell styles, but they do not support conditional formatting, and these are for individual cells, not an entire sheet.

    You can define a table style for an entire structured table, but it's only for font, border, and fill, not numeric formats, and not for conditional formatting.

    The one-click way to say "take all of the formatting on this sheet and apply it to this other sheet" are the two methods I described (well, OK, two clicks). You obviously have to at least select the source sheet and the destination sheet, so this logically cannot be done in one click.

    If you use a macro, you could add a custom button to the Ribbon to do it in one click. The code would retrieve the formatting from the saved template and apply it to the currently active sheet.

  5. #5
    Registered User
    Join Date
    08-30-2022
    Location
    East Coast, USA
    MS-Off Ver
    365 MSO Version 2202
    Posts
    13

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    I see. I think a Macro is what I want. Can you give me some pointers on how to make that macro?

    Attached is what I'm trying to do.
    Attached Files Attached Files

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    OK, you have some steps to follow. I am going to assume you are not familiar with VBA.

    Save your template to a folder where it is going to live.
    In Excel press ALT+F11. This will open the VBA development window.
    On the left side of the window, you will see a list of open files. At the top you should see PERSONAL.xlsb.
    Right-click on PERSONAL.xlsb and select Insert > Module
    If you do not have any macros yet, you will now have a folder under PERSONAL.xlsb called Modules, and a component under that called Module1.
    Double click on Module 1. You should see a blank window to the right. This is the code for Module1.
    Copy the following code and paste it into that window. Update the red part to match your path.
    Please Login or Register  to view this content.
    Click the little "save" icon in the menu bar of the VBA environment. This will save changes to the PERSONAL.xlsb file.
    Close the VBA window
    Back in Excel, right-click on any button in the Ribbon and select Customize the ribbon....
    Now you can create a custom group in the Ribbon, add a button to it, and assign the macro to the button. If it is not clear what to do from looking at the window, let me know and I will give more detailed instructions for this part.

  7. #7
    Registered User
    Join Date
    08-30-2022
    Location
    East Coast, USA
    MS-Off Ver
    365 MSO Version 2202
    Posts
    13

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    Worked like a charm! Thank you so much! Thank you for your time and detailed responses.

    I assume that any modification I make to the template will now be applied to future sheets?

    This link shows you how to assign a button to a macro: https://support.microsoft.com/en-au/...b-dd6bce669f25

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    Yes, it uses the current version of the template every time so changes will be applied.

  9. #9
    Registered User
    Join Date
    08-30-2022
    Location
    East Coast, USA
    MS-Off Ver
    365 MSO Version 2202
    Posts
    13

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    Thanks again!

  10. #10
    Registered User
    Join Date
    08-30-2022
    Location
    East Coast, USA
    MS-Off Ver
    365 MSO Version 2202
    Posts
    13

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    Another question:

    Is there a way to pre-format column widths? The formatting from the code above applies to all cells, but the width of the downloaded report does not change.
    I tried adding the code below to the previous, but got the error code attached:

    Please Login or Register  to view this content.
    I also tried to add it after the End Sub, but that didn't reformat the new downloaded report.
    How do I add this to the formatting?
    Attached Images Attached Images

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Applying Predetermined Formatting/Logic to a Downloaded Table

    You tried to put a sub in the middle of another sub. Illegal syntax. Simplest fix is remove the Sub and End Sub lines.

+ 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. [SOLVED] Fuzzy logic file downloaded but doesn't appear in power query
    By scolou2000 in forum Excel General
    Replies: 2
    Last Post: 03-29-2022, 09:53 AM
  2. Applying IF logic as VBA down whole column for 5000 rows
    By Ravenous in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2017, 10:11 PM
  3. [SOLVED] Selectively transposing data from a downloaded csv file to populate an existing table.
    By watkincm in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-02-2016, 11:14 AM
  4. Programme to turn downloaded data into a form that's recognised by pivot table
    By suesein in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2014, 03:49 AM
  5. Excel 2007 : help with matching downloaded file to a table
    By catherine3 in forum Excel General
    Replies: 0
    Last Post: 11-01-2011, 02:13 PM
  6. Replies: 2
    Last Post: 08-06-2008, 12:13 PM
  7. Applying Formatting to Pivot Table
    By vijay_sankar in forum Excel General
    Replies: 1
    Last Post: 04-18-2007, 08:57 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