LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Help with macro to find matching data between two worksheets

Hello

I am working on a macro to compare two worksheets to identify matching data.
I have got this to work nicely, but am now trying to make it as user-friendly
as possible so that others can use it without modifying the code. So far I
have got the macro to present the user with three input boxes:

---The 1st asks the user to specify what text the macro will place in a
field to indicate that the record was found.

---The 2nd asks the user to select the range of cells containing the data
they are trying to match.

---The 3rd asks the user to indicate which worksheet the macro has to look
at to find any matching data.

What I am having trouble with is: (1) how to get the user to also specify
the range of cells the macro has to look at to find the data, and (2) how to
get the user to specify the column in which to place the text specified in
the 1st input box.

The code I have so far is below:

Sub FindData()

Dim c As Range
Dim findC As Variant

Response = InputBox(Prompt:="Enter message to place in Cells")

Set MyRange = Application.InputBox( _
Prompt:="Select the range of cells containing the data you are looking
for:", Type:=8)

ComparisonSheet = InputBox( _
Prompt:="Enter the name of the worksheet you wish to investigate?")

Set Sht = MyRange.Parent

For Each c In MyRange
If Not c Is Nothing Then
Set findC = ActiveWorkbook.Sheets(ComparisonSheet).Cells _
.Find(c.Value, LookIn:=xlValues)
If Not findC Is Nothing Then
' Within the quotation marks below enter the Column you want the comments to
appear in
Sht.Range("G" & c.Row).Cells.Value = Response
End If
End If
Next
Excel.Application.SendKeys Keys:="^{HOME}", Wait:=True
DoEvents
MsgBox "Investigation completed."

End Sub


As you can see, the macro looks at the entire worksheet (as specified by the
user in the 3rd input box) to find the matching data. But my preference would
be that the user can also specify the range in that worksheet. This way they
can select the entire worksheet or just a column within the worksheet.

Also, as you can tell from the above code, the macro will place the text (or
response) in the corresponding row in column G of the active worksheet. I
would like the user to be able to either specify the column in which the text
is to be placed, or to have the macro automatically place the text in the
first column after the range of data.

I hope this all makes sense.

Any help would be most appreciated as I'm at a loss.

Joe.

--
If you can measure it, you can improve it!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
matching 2 worksheets to find differences Vic Excel Discussion (Misc queries) 2 April 2nd 09 09:58 PM
How do I compare data in two worksheets to find matching cells? Gary Excel Discussion (Misc queries) 4 March 2nd 06 09:04 PM
Find Matching Records in Two Worksheets kittybat Excel Discussion (Misc queries) 2 April 5th 05 06:51 PM
Find matching records in two worksheets kittybat Excel Discussion (Misc queries) 3 March 30th 05 12:11 AM
Find Matching Data in different columns of different worksheets No Name Excel Programming 0 June 30th 04 10:02 PM


All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"