How to do recursive searches in Excel

Closed
pacman849 Posts 1 Registration date Thursday 19 June 2014 Status Member Last seen 19 June 2014 - 19 Jun 2014 à 10:59
venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 - 20 Jun 2014 à 08:26
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.
Related:

1 response

venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 811
20 Jun 2014 à 08:26
" 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