lookup and loop in Macro

Mickey66

New Member
Joined
Mar 25, 2011
Messages
7
Hi Excel experts, this girl typing here at mid night because I can not fall asleep, this macros drove me crazy that i have nothing to do but banging my head on the desk...

I have two worksheets: WK1, WK2

in WK1, I have two columns:
Col A is a list of tag# (starts from A2,A3,A4...)
Col B is indicators, it tells me if the Tag# in colA can be found in WK2 bolded. if it is bolded in WK2, Col B says "Yes", otherwise, it says "not in record"
So, it looks like the following:
A B
tag#1 yes
tag#2 not in record
....... ......

In WK2, column A is also a list of tag#
---------------------------------------------------
Now, what I want to do in macro is:
in WK1, if the tag# (say cell "A2" tag#2) is indicated as "not in record", then lookup this tag#2 in WK2,
if it can find this tag# in WK2, then bold this tag# in WK2;
if it can not find this tag# in WK2, then add this tag# to the next available empty row in the same column where the tag# entered, and then bold it.
After the above exersice for cell A2 for example, Then, it will lookup A3 and repeat the above action, then lookup A4,A5,A6... till the end of the list of WK1
---------------------------------------------------
Is this possible??:confused:
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hey Mickey66,

Maybe this will work:

Code:
Sub Mickey66()
For i = 2 To Sheets("WK1").UsedRange.Count
    If Sheets("WK1").Cells(i, 2) = "not in record" Then
        Set r = Sheets("WK2").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row).Find(Sheets("WK1").Cells(i, 1).Value)
        If Not r Is Nothing Then
            r.Font.Bold = True
        Else
            Sheets("WK2").Range("A" & Sheets("WK2").Cells(Rows.Count, 1).End(xlUp).Row + 1) = Sheets("WK1").Cells(i, 1).Value
            Sheets("WK2").Range("A" & Sheets("WK2").Cells(Rows.Count, 1).End(xlUp).Row).Font.Bold = True
        End If
    End If
Next
End Sub
 
Upvote 0
Oh my god!! It works just so perfectly!!! I don't know how much thank you I can say to you syntaxed to express my feeling now!!

This was my first posting here after I registered and struggled for a long while! and..I don't know what to say but thank you very much!

Have a great day syntaxed!!:biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,476
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top