+ Reply to Thread
Results 1 to 13 of 13

Formatting Macro

  1. #1
    Registered User
    Join Date
    07-26-2006
    MS-Off Ver
    Office 365
    Posts
    97

    Formatting Macro

    Hello,

    I posted this in Commercial Services but did not get a response.

    I am somewhat new to macros and have one I thought would be simple. I tried recording the macro but quickly found myself out of my depth.

    I have multiple sheets with data in table form. Each sheet has the same exact headers (headers are in the range A10:AE10) but the number of rows vary.

    The formats for each column vary from General, Accounting, Number, Date etc, and may change in the future.

    I am in need of a macro that can go into specific sheets and reformat the range of data in the columns based on the format of a specific range of cells in another sheet.

    I have a master range, on a sheet I named “Master”. In cells A1:AE1, Here is where I have set my formats. (I figured it would be easier to change the formats here if things change)

    The macro will apply only to the tabs that start with a "T" or "J" (The J sheets are the "Job ####" sheets of the attached)

    It will then go to first sheet, find the range of data below the header (starting in A11 and going to AE?? since number of rows will vary), and format the data based on the formatting of the range from the Master tab (cell A1 format from the Master will equal the format for column A in the sheet)
    It would then apply a thin, solid border around the whole range and “dotted” borders within the range. (I am not sure how to describe the varying levels of borders, but it is the one directly below “None” on border selection).

    It would also have the ability to hide columns, say H, L, & P columns for this example.

    Once complete, it would move to the next sheet until all sheets that start with a J or T are formatted.

    There is another macro in the workbook called JobCodeOutput that the macro may be able to fit into. I kept my request as a separate macro not to confuse the issue.

    Any suggestions?
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Formatting Macro

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-26-2006
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Formatting Macro

    Hi Norie, Thank you for such a quick response! The macro works as it should. Thank you. However there are some other externalities that I realized I need to take care of. The other macro I run before this one, puts lines below the range this formatting macro selects, so those lines end up staying. Is there a way to clear the lines (or formatting) below the header, before this macro puts in the new formatting? Also is there a way to have the macro adjust column width to the same as in "Master"?

    Again, thank you for your feedback. It is greatly appreciated.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Formatting Macro

    Why don't you run the formatting code first?

  5. #5
    Registered User
    Join Date
    07-26-2006
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Formatting Macro

    Its the way the JobCodeOutput macro is set up. It basically creates new sheets based on values in the RollUp tab. Because it creates new sheets, I need to format the new sheets, therefore the formatting macro needs to run last. I did not create the JobCodeOutput and my attempts to fix the issue are a bit beyond my knowledge. If there is a way so the JobCodeOutput will create new sheets without the formatting, that could work to.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Formatting Macro

    Sorry you've kind of lost me.

    You mentioned the JobCodeOutput creating lines below the data to be formatted was a problem but now you seem to be saying it creating new sheets is the problem.

  7. #7
    Registered User
    Join Date
    07-26-2006
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Formatting Macro

    Sorry, let me back up.
    Are you able (or willing) to open the workbook? It could explain the issue a bit better, but I understand if you will not. I'll try to summarize below

    The JobCodeOutput macro, (which is in the attached workbook) looks at the RollUp tab, finds all unique values in column E, and then creates a new worksheet based on that unique value and returns all the rows with that value. The new worksheet is named "Job xxxx", where "xxxx" is unique value. In this example spreadsheet the JobCodeOutput creates about 20 new worksheets. When it goes to find the unique values and make a new sheet, the lines comes back weird. Sometimes there will only be 1 or 2 rows for the "xxxx" number but it creates lines for 20 rows.
    My end goal is to get a "clean" sheet for printing purposes. It does not look very good with formatted lines below the actual data range. I am hoping the formatting macro can clean up the issue.

    Again, Thank you!

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Formatting Macro

    Cardan

    I did open the file, how do you think I found out the first row of data is 19 and not 11?

    What I didn't do is run the JobCodeOutput.

    It's a bit late here to do that now but I'll give it a try tomorrow.

  9. #9
    Registered User
    Join Date
    07-26-2006
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Formatting Macro

    Yes you are right. the headers are in row 18 and the data starts in 19. To run the job code macro, first delete all the tabs named Job xxxx. the macro creates these and if the already exist, you get an error.

    No worries about the time. I greatly appreciate the effort.

  10. #10
    Registered User
    Join Date
    07-26-2006
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Formatting Macro

    Hi Norie,
    I played with the macro and I think I was able to remove the formatting from the JobCodeOutput macro and the formatting macro runs just fine. The only thing that would help if there is a way to have the macro copy the column widths in the master. Is this an easy insert? Thank you again.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Formatting Macro

    Cardan

    First off, sorry for not getting back to you.

    Applying the column widths from the 'Master' sheet to the other sheets should be straightforward.

    This is the code I tried for that - I've highlighted the column widths part.
    Please Login or Register  to view this content.
    However, that doesn't seem to make much difference.

    Can you give the above code a try and see how it works for you?

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Formatting Macro

    Quote Originally Posted by Cardan View Post
    Hello,

    I posted this in Commercial Services but did not get a response.
    I had replied to your thread there and even sent you a PM to increase your points. But you didnt reply.

    Also, its against the forum rules to post the thread in both the free forum and the paid forum at the same time. This time i will reverse your points through the technical team. But please remember for future reference.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  13. #13
    Registered User
    Join Date
    07-26-2006
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Formatting Macro

    Thank you Norie!

+ 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. Macro for formatting fonts and cell colours - not Conditional Formatting
    By Kayaness in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-07-2011, 03:46 AM
  2. Pivot Table graph looses formatting after running formatting macro
    By arthurbr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2011, 04:16 AM
  3. Conditional formatting macro (highlight macro)
    By c991257 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2007, 02:46 PM
  4. Macro Formatting? Please Help
    By Plasmaticfire in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2006, 03:05 PM
  5. RE: Macro Formatting? Please Help
    By Gary Brown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2006, 01:14 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