+ Reply to Thread
Results 1 to 5 of 5

Batch formatting ranges into tables with structured custom names

  1. #1
    Registered User
    Join Date
    10-01-2015
    Location
    DC
    MS-Off Ver
    2013 Pro Plus
    Posts
    22

    Exclamation Batch formatting ranges into tables with structured custom names

    Hi,

    Due to time constraints I need to troubleshoot the following code. Im a complete nub, so please help!
    I have 30 workbooks with 30 worksheets inside each on average. If my workbooks are named A,B,C..Z
    then my worksheets are A1, A2, A3....
    In each worksheet there are two tables (Attributes and Payments) which I'd like to convert into excel tables. The tables are located in the exact same ranges in every single worksheet.
    The tables are basically forms. I am trying to format those ranges by giving them custom names and not the ones auto-generated by excel. so for instance
    in Workboook A the first three worksheets, following (TableName="Pmt_" & WSName) rule, will have tables named like:
    worksheet A1: Att_A1, Pmt_A1
    worksheet A2: Att_A2, Pmt_A2
    worksheet A3: Att_A3, Pmt_A3

    The code below lets me chose a range of worksheet names (a range in fact from which the all of the tabs were created from) and then goes through the names one by one activating the sheets and converting the ranges into tables.

    But my code seems to be stuck right at the start where it is supposed to first activate the sheet whose name is next in the list.

    Any thoughts? THANK YOU IN ADVANCE

    HTML Code: 
    Last edited by gilliamwibson; 02-19-2016 at 02:03 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Batch formatting ranges into tables with structured custom names

    The macro recorder does a good job getting the syntax down, but does a poor job of navigating. Generally speaking, there is no need to select or activate anything, and if you ever see code like this:
    Please Login or Register  to view this content.
    It can almost always be replaced with
    Please Login or Register  to view this content.
    Also, your idea of what the active sheet or active cell is may be different than the code's idea of what these values are. A lot depends on where you are when you start recording your macro.

    The following code looks at every sheet in the workbook and checks to see if it starts with the letter "A." If it does, then it makes the two tables you want.

    Please Login or Register  to view this content.
    Last edited by dflak; 02-19-2016 at 05:33 PM.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    10-01-2015
    Location
    DC
    MS-Off Ver
    2013 Pro Plus
    Posts
    22

    Re: Batch formatting ranges into tables with structured custom names

    Wow thank you very much.

    My attach link doesn't work so I couldn't attach the spreadsheet. Is it possible I just select all the sheet names that I need the code to work on from the list they were created. (It is one short list as I said consisting of 30 entries on avg.) Have excel keep it as a string ("Selection", hence my original code) and instead of changing the code for each file every time I wanna run it I'd just make a new selection every time. Testing this now. But I hope you have time to consider my question.

    Kind regards

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Batch formatting ranges into tables with structured custom names

    Use a table to store the names of the sheets you want to process. Take a look at the attached, You will see that the code is almost identical.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-01-2015
    Location
    DC
    MS-Off Ver
    2013 Pro Plus
    Posts
    22

    Re: Batch formatting ranges into tables with structured custom names

    Thank you a lot. I sent a thank you earlier I must have messed up something it didn't go through! I tweaked the code to work with manual selection of tab names since as I said I created those tabs from a list.. son instead of naming lists in every file and I had 23 of them I just used Selection.
    Thank you again!!! worked like a charm..

+ 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] Cannot use structured references for tables
    By aliceinwonderland in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-09-2018, 01:29 PM
  2. Batch remove all custom cell styles using VBA
    By qaliq in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2015, 12:59 PM
  3. [SOLVED] Upper case month names in custom formatting
    By gak67 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-05-2014, 01:18 AM
  4. Structured Referencing tables
    By Tom_J_W in forum Excel General
    Replies: 8
    Last Post: 06-17-2013, 03:03 AM
  5. Conditional Formatting Using Names Ranges - No Errors?
    By brokenbiscuits in forum Excel General
    Replies: 0
    Last Post: 06-28-2012, 04:37 AM
  6. Batch charting, 2nd-axis threshold lines and custom formatting
    By Cameron Forward in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-18-2012, 11:26 AM
  7. [SOLVED] Batch Naming of ranges
    By Andy Chan in forum Excel General
    Replies: 4
    Last Post: 12-24-2005, 07:30 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