Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 02-18-2017, 09:47 AM
FUGMAN FUGMAN is offline Comparing between 2 worksheets and retreiving data if a match Windows 10 Comparing between 2 worksheets and retreiving data if a match Office 2016
Banned
Comparing between 2 worksheets and retreiving data if a match
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

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.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Index Match Function across different worksheets shay_mt Excel 2 04-27-2015 06:04 AM
Comparing between 2 worksheets and retreiving data if a match comparing data 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
Comparing between 2 worksheets and retreiving data if a match Comparing Data leroytrolley Excel 1 08-09-2008 08:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft