ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Modification in Recorded Macro (https://www.excelbanter.com/excel-programming/416328-modification-recorded-macro.html)

Dhimant

Modification in Recorded Macro
 
Hi,
I m trying below code
Sub Macro1()
Application.Goto Reference:="Sheet1!RC"
Selection.Copy
Application.Goto Reference:="'Sheet2'!RC"
Cells.Find(What:="NOV08987", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Application.CutCopyMode = False
End Sub

but at "NOV08987" I want to use sheet1!A1 Kindly
Thanks in advance for any tip or hint.
--
India

FSt1

Modification in Recorded Macro
 
hi
if i understand, you want to replace the result of the find on sheet 1 with
the value of RC on sheet1. if so...

Dim r As String
r = Sheets("sheet1").Range("A1").Value
Sheets("sheet2").Activate
Cells.Find(What:="NOV08987", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

ActiveCell.Value = r

or....
do you want to use the value of sheet1 A1 as the search criteria.
Dim r As String
r = Sheets("sheet1").Range("A1").Value
Sheets("sheet2").Activate
Cells.Find(What:=r, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

post back if i got it all wrong.

Regards
FSt1

"Dhimant" wrote:

Hi,
I m trying below code
Sub Macro1()
Application.Goto Reference:="Sheet1!RC"
Selection.Copy
Application.Goto Reference:="'Sheet2'!RC"
Cells.Find(What:="NOV08987", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Application.CutCopyMode = False
End Sub

but at "NOV08987" I want to use sheet1!A1 Kindly
Thanks in advance for any tip or hint.
--
India


Don Guillett

Modification in Recorded Macro
 
This is modified to find the value in sheet1!a1 somewhere in sheet 2 withOUT
selections.
Probably needs more refinement to finish what you want after you have found
it


sub getdatafromsheet2()
what = Sheets("sheet1").Range("a1")

myvalue = Sheets("sheet2").Cells.Find(what, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False) ' .address

MsgBox myvalue
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dhimant" wrote in message
...
Hi,
I m trying below code
Sub Macro1()
Application.Goto Reference:="Sheet1!RC"
Selection.Copy
Application.Goto Reference:="'Sheet2'!RC"
Cells.Find(What:="NOV08987", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Application.CutCopyMode = False
End Sub

but at "NOV08987" I want to use sheet1!A1 Kindly
Thanks in advance for any tip or hint.
--
India



Dhimant

Modification in Recorded Macro
 
thanks a lot second one is working
--
India


"FSt1" wrote:

hi
if i understand, you want to replace the result of the find on sheet 1 with
the value of RC on sheet1. if so...

Dim r As String
r = Sheets("sheet1").Range("A1").Value
Sheets("sheet2").Activate
Cells.Find(What:="NOV08987", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

ActiveCell.Value = r

or....
do you want to use the value of sheet1 A1 as the search criteria.
Dim r As String
r = Sheets("sheet1").Range("A1").Value
Sheets("sheet2").Activate
Cells.Find(What:=r, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

post back if i got it all wrong.

Regards
FSt1

"Dhimant" wrote:

Hi,
I m trying below code
Sub Macro1()
Application.Goto Reference:="Sheet1!RC"
Selection.Copy
Application.Goto Reference:="'Sheet2'!RC"
Cells.Find(What:="NOV08987", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Application.CutCopyMode = False
End Sub

but at "NOV08987" I want to use sheet1!A1 Kindly
Thanks in advance for any tip or hint.
--
India



All times are GMT +1. The time now is 12:59 PM.

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