If Found Then

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Need assist If value in Column T is found in Column H copy value adjacent to Column Z range A1
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Bill,

Are you expecting on value or many?
 
Upvote 0
Do we need to search all values in column T ?
Can you be a little clearer on this
copy value adjacent to Column Z range A1
??
 
Upvote 0
Yes All values in Column T if exist in Column H copy Column L value to Column Z

Thanks guys.

Example

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Column H[/TD]
[TD]Column L[/TD]
[TD]Column T[/TD]
[/TR]
[TR]
[TD]North West[/TD]
[TD]200[/TD]
[TD]West[/TD]
[/TR]
[TR]
[TD]West[/TD]
[TD]300[/TD]
[TD]North[/TD]
[/TR]
[TR]
[TD]South[/TD]
[TD]400[/TD]
[TD]South[/TD]
[/TR]
[TR]
[TD]South West[/TD]
[TD]500[/TD]
[TD]Pacific[/TD]
[/TR]
[TR]
[TD]Pacific[/TD]
[TD]250[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]South Pacific[/TD]
[TD]100[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]North[/TD]
[TD]450[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Untested

Code:
Sub TEST()
Dim TRange As Range, HRange As Range, lz As Long
Dim lt As Long, lh As Long, tcell As Range, hcell As Range
lt = Cells(Rows.Count, "T").End(xlUp).Row
lh = Cells(Rows.Count, "H").End(xlUp).Row
lz = Cells(Rows.Count, "Z").End(xlUp).Row
    Set TRange = Range("T2:T" & lt)
    Set HRange = Range("H2:H" & lh)
For Each tcell In TRange
    For Each hcell In HRange
        If hcell.Value = Range("T" & (tcell.Row)).Value Then
            Range("Z" & lz).Value = Range("L" & (hcell.Row)).Value
        lz = Cells(Rows.Count, "Z").End(xlUp).Row + 1
        End If
    Next hcell
Next tcell
End Sub
 
Last edited:
Upvote 0
Thank You very much

Modified a touch to work for my data.

Code:
lz = Cells(Rows.Count, "Z").End(xlUp).Row

to

Code:
lz = Cells(Rows.Count, "Z").End(xlUp).Row + 1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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