Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
hnyb1
 
Posts: n/a
Default Find and Update Macro

I have several macros written to update information in a spreadsheet based on
an entry into a input box. I need to change these macros to instead look at
a column of numbers in another file and find each number in my spreadsheet
and update. The following is an example of one of the macros:

Dim equipNum As String
Do
equipNum = InputBox("Scan in the Equipment Number. Type Done to Exit")

Cells.Find(What:=equipNum, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 3).Select
ActiveCell.FormulaR1C1 = "Y"

Loop Until equipNum = "Done"
Range("A1").Select

I am using Excel 2003 and only have a moderate grasp on macros. Any help
would be greatly appreciated!

Thanks,
Holly
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

How about this--but both workbooks need to be open:

Option Explicit
Sub testme()

Dim myCell As Range
Dim myListRng As Range
Dim myLookThroughRng As Range
Dim FoundCell As Range

With Workbooks("book1.xls").Worksheets("sheet1")
Set myListRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Workbooks("book2.xls").Worksheets("sheet99")
Set myLookThroughRng = .Range("a:a")
End With

For Each myCell In myListRng.Cells
With myLookThroughRng
Set FoundCell = .Cells.Find(what:=myCell.Value, _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, lookat:=xlWhole, _
MatchCase:=False, searchdirection:=xlNext)
End With
If FoundCell Is Nothing Then
'not found
MsgBox myCell.Value & " wasn't found in: " _
& myLookThroughRng.Address(external:=True)
Else
FoundCell.Offset(0, 3).Value = "Y"
End If
Next myCell

End Sub

You'll have to adjust the workbook names and worksheet names to match your
stuff.


hnyb1 wrote:

I have several macros written to update information in a spreadsheet based on
an entry into a input box. I need to change these macros to instead look at
a column of numbers in another file and find each number in my spreadsheet
and update. The following is an example of one of the macros:

Dim equipNum As String
Do
equipNum = InputBox("Scan in the Equipment Number. Type Done to Exit")

Cells.Find(What:=equipNum, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 3).Select
ActiveCell.FormulaR1C1 = "Y"

Loop Until equipNum = "Done"
Range("A1").Select

I am using Excel 2003 and only have a moderate grasp on macros. Any help
would be greatly appreciated!

Thanks,
Holly


--

Dave Peterson
  #3   Report Post  
hnyb1
 
Posts: n/a
Default

Thank you! This worked perfectly.

"Dave Peterson" wrote:

How about this--but both workbooks need to be open:

Option Explicit
Sub testme()

Dim myCell As Range
Dim myListRng As Range
Dim myLookThroughRng As Range
Dim FoundCell As Range

With Workbooks("book1.xls").Worksheets("sheet1")
Set myListRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Workbooks("book2.xls").Worksheets("sheet99")
Set myLookThroughRng = .Range("a:a")
End With

For Each myCell In myListRng.Cells
With myLookThroughRng
Set FoundCell = .Cells.Find(what:=myCell.Value, _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, lookat:=xlWhole, _
MatchCase:=False, searchdirection:=xlNext)
End With
If FoundCell Is Nothing Then
'not found
MsgBox myCell.Value & " wasn't found in: " _
& myLookThroughRng.Address(external:=True)
Else
FoundCell.Offset(0, 3).Value = "Y"
End If
Next myCell

End Sub

You'll have to adjust the workbook names and worksheet names to match your
stuff.


hnyb1 wrote:

I have several macros written to update information in a spreadsheet based on
an entry into a input box. I need to change these macros to instead look at
a column of numbers in another file and find each number in my spreadsheet
and update. The following is an example of one of the macros:

Dim equipNum As String
Do
equipNum = InputBox("Scan in the Equipment Number. Type Done to Exit")

Cells.Find(What:=equipNum, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 3).Select
ActiveCell.FormulaR1C1 = "Y"

Loop Until equipNum = "Done"
Range("A1").Select

I am using Excel 2003 and only have a moderate grasp on macros. Any help
would be greatly appreciated!

Thanks,
Holly


--

Dave Peterson

Reply
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
Data Range Mess Karen Charts and Charting in Excel 18 January 14th 06 02:34 PM
Unable to Record Macro murray Excel Discussion (Misc queries) 1 September 12th 05 10:22 PM
can't update links...can't find links GJR3599 Excel Discussion (Misc queries) 1 April 4th 05 04:56 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
refresh pivot tables through a macro dolph Excel Worksheet Functions 1 January 12th 05 03:16 AM


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

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

About Us

"It's about Microsoft Excel"