+ Reply to Thread
Results 1 to 7 of 7

Trying to use a match function to format a cell in VBA

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    UK
    MS-Off Ver
    Excel 2003 & 2007 (Different offices)
    Posts
    19

    Trying to use a match function to format a cell in VBA

    Hi there,

    as per previous posts I'm new to VBA and am trying teach myself as I go, so please, treat me like an idiot!

    I've just tried writting the following;
    Please Login or Register  to view this content.
    This is for a drawing register/tracker spreadsheet. the idea is, when a new a new drawing revision is recieved the new revision (C2, C2A, C2B, C3, C3A, . . . . ) is inserted into "J" column. I'm trying make the marco look along the top row to find the matching revision, and then format the corresponding cell in origianl row, I.e, if it i entered a new revision number into Cell "J5, it would look it up in row 1, and if the matching revision was in "H1", it would format "H5".

    I think my issue is (once again for anyone who say my last thread) a problem with getting used to VBA syntax as appose to normal worksheet syntax.

    Thanks in advance,

  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: Trying to use a match function to format a cell in VBA

    There's no need to apologize for not knowing something, nor feel silly asking a question on a forum setup and designed for this very purpose. The dumbest questions are the ones you should ask and don't.


    Anyway, a sample workbook might make it 100% clear what you're doing, but I imagine something like this if I understood your verbal correctly:

    Please Login or Register  to view this content.

    There are a myriad ways this could still be wrong, so hopefully this just gets the syntax corrected for you and you can tweak the targeting.
    _________________
    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
    08-13-2012
    Location
    UK
    MS-Off Ver
    Excel 2003 & 2007 (Different offices)
    Posts
    19

    Re: Trying to use a match function to format a cell in VBA

    Minor correction, this line hould read

    Please Login or Register  to view this content.
    Well, i say it should, it still doesn't work, but just thought I'd make that correction

    ---------- Post added at 03:33 AM ---------- Previous post was at 03:32 AM ----------

    Hi Jerry, I'll give that a try now. Just one thing, what does the the "Option Explicit" at the begining mean?

  4. #4
    Registered User
    Join Date
    08-13-2012
    Location
    UK
    MS-Off Ver
    Excel 2003 & 2007 (Different offices)
    Posts
    19

    Re: Trying to use a match function to format a cell in VBA

    Thanks Jerry, Good news and bad

    It did format a cell but. . seems to be formatting a cell 7/8 to right of where it should? I've attached the worksheet so hopefully you can see what I mean

    Also, What does "Option Explicit" do?
    Attached Files Attached Files

  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: Trying to use a match function to format a cell in VBA

    "What does Options Explicit do?" sounds like a perfect Google question.


    Your observations might have led you to an edit.... you're searching row1 for a match, but the match results in a colored cell 7 columns too far to the right? Maybe because the match values start in column 8? Heh,

    So, just correct the MATCH:
    Please Login or Register  to view this content.

    Seems odd to do with VBA what conditional formatting can do for free.
    Last edited by JBeaucaire; 08-15-2012 at 04:53 AM.

  6. #6
    Registered User
    Join Date
    08-13-2012
    Location
    UK
    MS-Off Ver
    Excel 2003 & 2007 (Different offices)
    Posts
    19

    Re: Trying to use a match function to format a cell in VBA

    Got you now! Thanks Jerry.

    Still getting used to the different commands in VBA, but at least thats this one clearer now. In answer to your question, about why not use conditional formatting? I want the this track which revisions we have recieved, so once a cell is formatted, it will stay formatted even when we update it and format another cell with a higher revision, and because we don't recieve every revision, i cannot use a "less then" type condition.

    Thanks again, I will no doubt, be back with more!

  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: Trying to use a match function to format a cell in VBA

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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