How to do recursive searches in Excel

Closed
pacman849 Posts 1 Registration date Thursday June 19, 2014 Status Member Last seen June 19, 2014 - Jun 19, 2014 at 10:59 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Jun 20, 2014 at 08:26 AM
Hi,
I have two worksheets. I need to be able to traverse a column in the first sheet and for each cell, compare it to a cell in the second sheet. If the content of a cell in the first sheet is found in the cell of the second, I need to be able to output a related cell from the second row.

I have the following "code", but need to make it into a VBA Macro, as I am not familiar with the syntax...

Variables
ServerRowNumber = 0
ServerName = ""
AppRowNumber = 0
AppServerCell = ""
AppCell = ""


For ServerRowNumber = 2 to 991
ServerName = Worksheets("Servers").Range("A'ServerRowNumber'").Value
For AppRowNumber = 2 to 339
AppServerCell = Worksheets("Apps").Range("B'AppRowNumber'").Value
If AppServerCell contains ServerName
Then
AppCell = Worksheet("Apps").Range("A'AppRowNumber'").Value
Write ServerName + ";" + AppCell
Else
Write ServerName + ";" + "**No Apps Found**"
Next AppRowNumber
Next ServerRowNumber

Any help gratefully received.

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Jun 20, 2014 at 08:26 AM
" I need to be able to output a related cell from the second row"

suppose "A" is in sheet 1 in row 1 column 1

suppose "A" is found in sheet 2 in row 4 column 1 then what to do
0