ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to match/compare cell values (https://www.excelbanter.com/excel-programming/350060-how-match-compare-cell-values.html)

tandavina

how to match/compare cell values
 

how do i compare/match cell value from worksheet 1 with 4 cell values
from worksheet 2?

please help, thank you.


--
tandavina
------------------------------------------------------------------------
tandavina's Profile: http://www.excelforum.com/member.php...o&userid=30334
View this thread: http://www.excelforum.com/showthread...hreadid=499997


MrScience

how to match/compare cell values
 
I'm sure it could be done using formulas directly in the Excel workbook
but I usually use VBA. Something like this could be used to compare 1
name entered in the first cell of Sheet 1 to 4 names entered into the
first 4 cells of column A in Sheet 2 . . .

Sub findMatch()
Dim myName As String
Dim findName As Variant
Dim loopCounter As Integer
myName = Sheets("Sheet1").Range("A1").Value
findName = Sheets("Sheet2").Range("A1:A4")
For loopCounter = 1 To 4
If myName = findName(loopCounter, 1) Then
MsgBox "Match Found! Hello " & myName
End If
Next loopCounter
End Sub



All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com