+ Reply to Thread
Results 1 to 10 of 10

Formatting unknown ranges based on contents of a column

  1. #1
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Formatting unknown ranges based on contents of a column

    Hi all,

    i can't seem to figure this one out.

    I attached a file showing how i am trying to format data (the second tab).

    The big issue is the counting to format. (the formatting itself is obviously easy.)

    The number of columns is not always standard so i need to count for it.

    the number of rows in each "room number" is also not always standard, which means i also need to count for those.

    If anyone has had experience trying to do something like this i would appreciate the help.

    i know it is possible because i had one that someone had given me years ago, unfortunately i lost it in a hard drive failure...also years ago.

    if it isn't obvious what i am trying to do, let me know and i will try to be clearer.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formatting unknown ranges based on contents of a column

    Give this macro a try:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Re: Formatting unknown ranges based on contents of a column

    that seems to work out the basic idea, i am going to play with it a bit and see if can figure out the bugs, i will let you know what i find.

  4. #4
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Re: Formatting unknown ranges based on contents of a column

    ok so i have come to the conclusion that the part that is making it not work is the "myval = worksheetfunction.max(columns(2)).

    reason, some of the room numbers have letters in the number, ie 127B. i think this is throwing off the MAX function...unfortunately i can't figure out a workaround.

    any ideas?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formatting unknown ranges based on contents of a column

    Yep, that would break the whole thing. MAX() needs numbers. You provided a dataset that did not properly represent all your needs. (nudge)

    If you know what all the room numbers are going to be, post up a full representation and we'll take another crack at this.

  6. #6
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Re: Formatting unknown ranges based on contents of a column

    Yah. Sorry about that, i didn't want to overwhelm anyone willing to help with to much information.

    The best i can tell the only thing that is not accurately represented is the room numbers. At times the Room numbers could have B103, or 127A, or 127B, etc. I think that is only discrepancy.

    (and the part numbers would actually be a string of letters and numbers i.e. CB78TG5, or the like, but since we are not using that column to dictate the formatting i don't think it matters.)

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formatting unknown ranges based on contents of a column

    You know, if you post up a sample workbook that truly represents ALL the hurdles to overcome, perhaps I can think of something. Your original book doesn't do that, so beef it up to cover everything and let's have another look.

  8. #8
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Re: Formatting unknown ranges based on contents of a column

    Ok if you think it will help.

    I think this is a fairly typical example.

    Thanks for your help btw.
    Attached Files Attached Files

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formatting unknown ranges based on contents of a column

    Once more around the block:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-19-2009
    Location
    California
    MS-Off Ver
    Excel 2013-16
    Posts
    55

    Re: Formatting unknown ranges based on contents of a column

    Well i thought that last one had done it... but as i have begun playing with it it seems to freeze excel to the point of where it never recovers.

    Do you have any ideas why it would be doing that?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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