VBA finding matching value in different column

haxor

New Member
Joined
Jul 5, 2020
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi All

I need to match column T (20) value and see if it exists in column N where the column A value and the Column I values are equal. if it finds it, it needs to write the value: "502"
in column 7 where it found it

For example for row 7 and 8, column A and column I matches, so it needs to check the value in column T which is 8 in row 8. Column N in row 8 doesn't have the value but row 7 has.

The value for Row 7, column G needs to populate the value 502 because it found a matching value

The same for Row 11, 12 and 13 as their column A and column I matches, so it needs to check the value in column T which is 5 in row 13. Column N in row 13 doesn't have the value but row 12 has.

I have the following code (There is other code as well but I think this is the problem piece):

VBA Code:
 If .Cells(counter, 1).Value = .Cells(counter + 1, 1).Value And .Cells(counter, 9).Value = .Cells(counter + 1, 9).Value Then
      
'.Cells(counter, 20).Value > 0 And
        
       Dim FoundCell As Range
       Dim ws As Worksheet
       Set ws = Sheets("Mini")
       Dim WHAT_TO_FIND As Integer

       WHAT_TO_FIND = .Cells(counter, 20).Value

       Set FoundCell = ws.Range("N:N").Find(What:=WHAT_TO_FIND)

       If Not FoundCell Is Nothing Then
                .Cells(counter, 7).Value = "502"
                MsgBox ("Found")
        Else
                .Cells(counter, 7).Value = "501"
                MsgBox ("Not Found")
                
        
            End If


   End If

Excel.gif
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
There is something else that I am struggling with. Can I put the details here? It is still related to the Post and Sheet or do I have to create a new Post?
 
Upvote 0
As the problem of this thread has already been resolved and you are talking about another macro, you should create a new thread, there you describe the complications you have with both macros.
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,352
Members
449,080
Latest member
Armadillos

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