![]() |
#9
|
|||
|
|||
![]()
NoSparks
Sorry that it has taken me so long to reply, but it has been busy here. Once again, you delivered in spades. Thank you. Actually, the second method is a better solution than the first. The data source for my activity is two fold. The second approach was chosen after I discovered the 2nd source. Using the code you provided eliminates a manual intermediate step in my process. This accomplished by using multiple "if-than-else" in your code. EXAMPLE str = "Address" 'str = InputBox("Enter what to search for", "SEARCH CRITERIA") If str = "" Then Exit Sub Set ws = Sheets("DATA ENTRY") '<~~ change to suit col = 1 '<~~ change to suit ~~~ column 7 is "G" On Error Resume Next 'if nothing found it errors r = Application.WorksheetFunction.Match(str, ws.Columns(col), 0) On Error GoTo 0 'turn error notification back on 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX If r > 0 Then If ws.Cells(r + 1, col) = "" Then ws.Range("I8").Value = "not found" Else ws.Range("I8").Value = ws.Cells(r + 1, col).Value End If Else MsgBox "Didn't find " & str End If 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X 'CITY If r > 0 Then If ws.Cells(r + 2, col) = "" Then ws.Range("I9").Value = "not found" Else ws.Range("I9").Value = ws.Cells(r + 2, col).Value End If Else MsgBox "Didn't find " & str End If 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X 'STATE If r > 0 Then If ws.Cells(r + 3, col) = "" Then ws.Range("I11").Value = "not found" Else ws.Range("I11").Value = ws.Cells(r + 3, col).Value End If Else MsgBox "Didn't find " & str End If 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X 'ZIPCODE If r > 0 Then If ws.Cells(r + 4, col) = "" Then ws.Range("I12").Value = "not found" Else ws.Range("I12").Value = ws.Cells(r + 4, col).Value End If Else MsgBox "Didn't find " & str End If Thanks again. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Index Match Function across different worksheets | shay_mt | Excel | 2 | 04-27-2015 06:04 AM |
![]() |
sjp1966 | Excel | 6 | 07-23-2014 11:43 AM |
Comparing two excel worksheets | SaneMan | Excel | 1 | 06-27-2012 07:52 PM |
Comparing Data - MS Excel | ramadevidokkuud | Excel | 1 | 05-19-2011 05:52 AM |
![]() |
leroytrolley | Excel | 1 | 08-09-2008 08:34 PM |