VBA code that needs restructuring

Estatefinds

Board Regular
Joined
Sep 14, 2015
Messages
169
I have a code that when run it will search for data from one column and searches for its match in numerous other columns; specifically every 8 columns where data is found and it returns the the row on which that matching data is found.
What i need is for someone to help me change the code so it will search in only one column and return the row it is found on.

(code)
sub my search()
For each gcell in Range("g1", range(G65536").End(xlup))
If isempty(cell(gcell.row, 8)) Then
For each c in Range ("Z1:AOOO324597")
I=Application.match(gcell.value, Range(c, Cells(324597, c.column)), 0)
if Not iserror(I) Then
Cells(gcell.row,8)=I
exit for
end if
next
if is empty(cells(gcell.row, 8)) then
cells(gcell.row, 8) ="$#N/A"
end if
end if
next
end sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
so the data wont be spread across multiple columns, I had placed the data in only one column. this was done for easier reading. the range of data is the same except the data that will be in column Z only instead of from column Z to AOO.
 
Upvote 0
Sub mySearch()
For Each gCell In Range("G1", Range("G65536").End(xlUp))
If IsEmpty(Cells(gCell.Row, 8)) Then
For Each c In Range("Z1:AOO324597")
I = Application.Match(gCell.Value, Range(c, Cells(324597, c.Column)), 0)
If Not IsError(I) Then
Cells(gCell.Row, 8) = I
Exit For
End If
Next
If IsEmpty(Cells(gCell.Row, 8)) Then
Cells(gCell.Row, 8) = "#N/A"
End If
End If
Next
End Sub
 
Upvote 0
So, your trying to match a cell in column "G" with COL "Z"....is that correct ??
 
Upvote 0

Forum statistics

Threads
1,215,537
Messages
6,125,394
Members
449,222
Latest member
taner zz

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