Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

FIND Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaveM - 28 May 2008 19:11 GMT
Hi

Code Needed to do this from a macro,

Sheet1 cell A1, the value in this cell changes.

How can I get the content of this cell and put it in a Find Macro,

Then goto Sheet2 Column A, and find down that column for what was in sheet1
A1. the value in sheet1 A1 changes sometimes.

Thanks in advance

Dave
Gary Keramidas - 28 May 2008 19:59 GMT
what columns are you searching on sheet2, all of them? this is similar to what i
posted to another question. just change the ranges and sheet names.

Sub test()
     Dim ws As Worksheet, ws2 As Worksheet
     Dim rngfound As Range
     Dim rng As Range
     Dim toFind As String
     Set ws = Worksheets("Sheet1")
     Set ws2 = Worksheets("Sheet2")
     Set rng = ws2.Range("A1:A30")
     toFind = ws.Range("A1").Value
     With rng
           Set rngfound = .Find(toFind, lookat:=xlWhole, LookIn:=xlValues)
     End With
     If Not rngfound Is Nothing Then
           Application.Goto ws2.Range("A" & rngfound.Row), scroll:=True
     End If

End Sub

Signature

Gary

> Hi
>
[quoted text clipped - 10 lines]
>
> Dave
DaveM - 28 May 2008 20:55 GMT
Hi Gary thanks for the reply

I need to find in sheet2 Column A

Thanks

Dave

> what columns are you searching on sheet2, all of them? this is similar to
> what i posted to another question. just change the ranges and sheet names.
[quoted text clipped - 31 lines]
>>
>> Dave
Gary Keramidas - 28 May 2008 21:06 GMT
adapt this to your needs

Sub test()
     Dim ws As Worksheet, ws2 As Worksheet
     Dim rngfound As Range
     Dim rng As Range
     Dim toFind As String
     Set ws = Worksheets("Sheet1")
     Set ws2 = Worksheets("Sheet2")
     Set rng = ws2.Columns("A:A")
     toFind = ws.Range("A1").Value
     With rng
           Set rngfound = .Find(toFind, lookat:=xlWhole, LookIn:=xlValues)
     End With
     If Not rngfound Is Nothing Then
           Application.Goto ws2.Range("A" & rngfound.Row), scroll:=True
     End If

End Sub

Signature

Gary

> Hi Gary thanks for the reply
>
[quoted text clipped - 39 lines]
>>>
>>> Dave
DaveM - 28 May 2008 21:24 GMT
Works great

Thanks Gary

All the Best

Dave

> adapt this to your needs
>
[quoted text clipped - 61 lines]
>>>>
>>>> Dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.