ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FIND Macro (https://www.excelbanter.com/excel-programming/411648-find-macro.html)

DaveM[_2_]

FIND Macro
 
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

FIND Macro
 
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




--


Gary


"DaveM" wrote in message
. uk...
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







DaveM[_2_]

FIND Macro
 
Hi Gary thanks for the reply

I need to find in sheet2 Column A

Thanks

Dave


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
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




--


Gary


"DaveM" wrote in message
. uk...
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

FIND Macro
 
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

--


Gary


"DaveM" wrote in message
. uk...
Hi Gary thanks for the reply

I need to find in sheet2 Column A

Thanks

Dave


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
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




--


Gary


"DaveM" wrote in message
. uk...
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











DaveM[_2_]

FIND Macro
 
Works great

Thanks Gary

All the Best

Dave


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
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

--


Gary


"DaveM" wrote in message
. uk...
Hi Gary thanks for the reply

I need to find in sheet2 Column A

Thanks

Dave


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
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




--


Gary


"DaveM" wrote in message
. uk...
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














All times are GMT +1. The time now is 10:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com