Comparing two lists

everscern

Board Regular
Joined
Oct 10, 2006
Messages
56
aaa-2.jpg


hi all. One more question till the end of my project. so your response is very much appreciated.

See cell B36. The number 6 should be 20. but the macro compares it with the above circled data. How do i modify it?

Thanks so much.

Right now my code is like this:

Code:
Private Sub SMIDialog_Button18_Click()
Dim txt As String, r As Range

   If WorksheetFunction.CountA(Range("b31:b35")) <> 5 Then Exit Sub
   Range("b36") = Empty
   txt = Range("b31").Text & "_" & Range("b32").Text & "_" & Range("b33").Text & "_" & Range("b34").Text & "_" & Range("b35").Text
   For Each r In Range(("S31:T36"), Cells(2, Columns.Count).End(xlToLeft))
      If txt = r.Text & "_" & r.Offset(1).Text & "_" & r.Offset(2).Text & "_" & r.Offset(3).Text & "_" & r.Offset(4).Text Then
         Range("b36").Value = r.Offset(5).Value
         Exit For
      End If
   Next

End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi

Try changing

For Each r In Range(("S31:T36"), Cells(2, Columns.Count).End(xlToLeft))

to

For Each r In Range(("S31:T36"), Cells(31, Columns.Count).End(xlToLeft))


Tony
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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