-
Apr 24th, 2021, 10:56 AM
#1
Thread Starter
Addicted Member
[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
-
Apr 25th, 2021, 03:58 AM
#2
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
-
Apr 26th, 2021, 12:49 PM
#3
Thread Starter
Addicted Member
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?
-
Apr 27th, 2021, 04:21 AM
#4
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
-
Apr 27th, 2021, 09:47 AM
#5
Thread Starter
Addicted Member
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
-
Apr 28th, 2021, 04:58 AM
#6
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
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
-
Apr 28th, 2021, 10:37 AM
#7
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|