+ Reply to Thread
Results 1 to 5 of 5

Macro with ranges based on border format

  1. #1
    Registered User
    Join Date
    02-20-2013
    Location
    Boston, Massachusetts
    MS-Off Ver
    365
    Posts
    13

    Macro with ranges based on border format

    This is an example of the sort of files I work on every week.

    - It is NEVER guaranteed that certain keywords will be in the same column from project to project.
    - But "Scenes Liked" and "Scenes Disliked" will ALWAYS be directly left to the regions in question.
    - Similarly, the regions in question will ALWAYS be formatted with borders (nothing else in the data set will).

    Border Example LD.JPG

    I need to change the contents of the FIRST bordered region (D1:M1) from the unique text in each cell to "sc1" "sc2" "sc3" etc.
    E.g. "Smith finds out he has a clone" CHANGES TO "sc1" / "Logos" CHANGES TO "sc2"

    And I need to change the contents of the SECOND bordered region (P1:Y1) from the unique text in each cell to "scd1" "scd2" "scd3" etc.
    E.g. "Smith finds out he has a clone" CHANGES TO "scd1" / "Logos" CHANGES TO "scd2"


    This is part of the code I've been using, located in a SEPARATE workbook.
    The macro finds "Scenes Liked," offsets by one, and sets the range as ActiveCell xlToRight.
    It then finds the FIRST cell in that range that does NOT contain a formatted border and inserts a blank column before performing its other functions.

    Please Login or Register  to view this content.
    The same sort of code is then used for the SECOND region, "Scenes Disliked."



    Whenever I try running the macro I receive this error message:

    Capture.JPG


    And the debugger highlights this section of code:
    Please Login or Register  to view this content.


    Any thoughts on how to fix this error or avoid it altogether with a different approach?
    (Macro file attached, specific to Private Sub PivotDomestic section)
    Attached Files Attached Files
    Last edited by sxj; 01-08-2020 at 11:28 AM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,605

    Re: Macro with ranges based on border format

    Administrative note

    If you are not using XL2003 any more,please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Members tailor answers based on your Excel version.

    Also in the future please post in the correct forum. I will move it for you
    Thanks

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Macro with ranges based on border format

    Can you provide a sample workbook which includes the formatted data as well? It's difficult trying to find a solution in the dark. My best guess for a simpler start to the macro would be:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  4. #4
    Registered User
    Join Date
    02-20-2013
    Location
    Boston, Massachusetts
    MS-Off Ver
    365
    Posts
    13

    Re: Macro with ranges based on border format

    Wow - this worked perfectly! It does exactly what I need it to and it's such a better approach. Thank you so much for your help!

  5. #5
    Registered User
    Join Date
    02-20-2013
    Location
    Boston, Massachusetts
    MS-Off Ver
    365
    Posts
    13

    Re: Macro with ranges based on border format

    Quote Originally Posted by Pepe Le Mokko View Post
    Administrative note

    If you are not using XL2003 any more,please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Members tailor answers based on your Excel version.

    Also in the future please post in the correct forum. I will move it for you
    Thanks
    Will do, thank you!

+ 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. Add a border around multiple ranges which are dynamic
    By muss1210 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2017, 08:14 AM
  2. Format .. Border .. I need a thicker border
    By Trebor777 in forum Excel General
    Replies: 1
    Last Post: 10-26-2016, 09:41 AM
  3. [SOLVED] Excel Macro to Add Buttom Double Border to Rows Based on Criteria
    By eitan932 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2016, 07:02 AM
  4. [SOLVED] Excel Macro to Add Buttom Double Border to Rows Based on Criteria
    By eitan932 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2014, 05:17 AM
  5. Format Border color based on value
    By jeff.p in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-05-2007, 04:13 PM
  6. Conditional Format based on date ranges
    By Corey in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-31-2006, 12:40 AM
  7. Macro to Conditionally format Thick Border
    By nuver in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-06-2005, 08:05 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