Results 1 to 7 of 7

Thread: [RESOLVED] excel 2000 question

  1. #1

    Thread Starter
    Addicted Member habenero's Avatar
    Join Date
    Aug 2015
    Posts
    224

    Resolved [RESOLVED] excel 2000 question

    I have a spreadsheet that has names (text) on rows and columns.

    They appear only twice. What I am looking for is the syntax (macro) to find that name in whatever row and column and color that cell.

    I can use the macro recorder to color up an individual cell and of course it works but its referenced to that cell and not the contents.

    If someone can give - point me to the solution I would appreciate it

    Jeff

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: excel 2000 question

    you can use excels find method, to find cell with matching text

    Code:
    Set fnd = sht.UsedRange.Find(cel)
    if not fnd is nothing then fnd.interior.color = vbred
    where sht is a worksheet object and cel is a range object that have both been set previously, though you can just use literals for sheet and range
    change object names and color to suit, if there is no match then nothing happens

    also there is several options for the find method, some of which may need to be used
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Addicted Member habenero's Avatar
    Join Date
    Aug 2015
    Posts
    224

    Re: excel 2000 question

    Hello

    and thanks for the reply

    So as I see it the (cel) would be what I am searching for?

    Also the used range - I need to define that as the worksheet row and columns are always static

    and then targeted / desired tect would be highlighted as needed?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: excel 2000 question

    Also the used range - I need to define that as the worksheet row and columns are always static
    usedrange is a property of a sheet object and would work as posted would work, but you can always choose the range to search in, but as you did not give any clues about which column ( or if they would all be in the same column) to search in i just used the used range as being the smallest range to cover all bases and return the result based on your description

    you did not explain if you would just search for one result or you wanted to run a loop to highlight all matching results
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Addicted Member habenero's Avatar
    Join Date
    Aug 2015
    Posts
    224

    Re: excel 2000 question

    thanks so much for the help

    yes there are going to be multi-searchs (maybe 6 or 7) and in the used range. I do now get it that the used range is a global.

    but again the "(cel) would be my target text? and my searches could be "hard coded" as they never change

    Jeff

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: excel 2000 question

    but again the "(cel) would be my target text? and my searches could be "hard coded" as they never change
    of course they can be hard coded, i assumed that you would want to match the value of some cell as
    They appear only twice.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    Addicted Member habenero's Avatar
    Join Date
    Aug 2015
    Posts
    224

    Re: excel 2000 question

    Ok and so many thanks for the guidance

    stay safe ; this is solved

    Jeff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width