Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Fiind from textbox and paste into sheet1

Here is the problem. I am not able to get the info to paste into sheet1. I
can use the find function to find the cell but not able to paste. I would
also like to mention that I have multiple text boxes to search from. If
anyone can help i would greatly appreciate it. Thanks
-mark
Private Sub cmdFind_Click()
Dim R As Range
Dim Sheet As Worksheet
Sheets("sheet1").Select
Sheets("Sheet2").Select
Cells.Find(What:=txtFind.Text, After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Fiind from textbox and paste into sheet1

Here is some code that should work for you. I did not know where you wnated
the item pasted (paste regular or paste special for that matter) so I pasted
regular in the first blank cell in column a on the destination sheet. It is
important when doing a find to handle the case when it is not found. I just
did a message back to the user...

Private Sub cmdFind_Click()
Dim wksCopyFrom As Worksheet
Dim wksCopyTo As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngCopyTo As Range

Set wksCopyFrom = Sheets("Sheet1")
Set rngToSearch = wksCopyFrom.Cells
Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, xlWhole)
If rngFound Is Nothing Then
MsgBox "That item was not found."
Else
Set wksCopyTo = Sheets("Sheet2")
Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(1,
0)
rngFound.Copy rngCopyTo
End If

End Sub
--
HTH...

Jim Thomlinson


"Mark Cover" wrote:

Here is the problem. I am not able to get the info to paste into sheet1. I
can use the find function to find the cell but not able to paste. I would
also like to mention that I have multiple text boxes to search from. If
anyone can help i would greatly appreciate it. Thanks
-mark
Private Sub cmdFind_Click()
Dim R As Range
Dim Sheet As Worksheet
Sheets("sheet1").Select
Sheets("Sheet2").Select
Cells.Find(What:=txtFind.Text, After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Fiind from textbox and paste into sheet1

Thanks so much for your reply Jim. This is working but i still have a need
to past all of the contents of the row from which the cell was found. also i
would like to be able to search the entire workbook that contains 9 sheets,
and paste it in sheet 1. Thanks so much for your help.
-Mark

"Jim Thomlinson" wrote:

Here is some code that should work for you. I did not know where you wnated
the item pasted (paste regular or paste special for that matter) so I pasted
regular in the first blank cell in column a on the destination sheet. It is
important when doing a find to handle the case when it is not found. I just
did a message back to the user...

Private Sub cmdFind_Click()
Dim wksCopyFrom As Worksheet
Dim wksCopyTo As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngCopyTo As Range

Set wksCopyFrom = Sheets("Sheet1")
Set rngToSearch = wksCopyFrom.Cells
Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, xlWhole)
If rngFound Is Nothing Then
MsgBox "That item was not found."
Else
Set wksCopyTo = Sheets("Sheet2")
Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(1,
0)
rngFound.Copy rngCopyTo
End If

End Sub
--
HTH...

Jim Thomlinson


"Mark Cover" wrote:

Here is the problem. I am not able to get the info to paste into sheet1. I
can use the find function to find the cell but not able to paste. I would
also like to mention that I have multiple text boxes to search from. If
anyone can help i would greatly appreciate it. Thanks
-mark
Private Sub cmdFind_Click()
Dim R As Range
Dim Sheet As Worksheet
Sheets("sheet1").Select
Sheets("Sheet2").Select
Cells.Find(What:=txtFind.Text, After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Fiind from textbox and paste into sheet1

The best way to search all of the sheets depends on how many sheets you do
not want to search. Obviously you do not want to search the sheet you are
pasting to. You will also need to specify any other sheets that need to be
excluded in this code

Private Sub cmdFind_Click()
Dim wksCopyFrom As Worksheet
Dim wksCopyTo As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngCopyTo As Range

Set wksCopyTo = Sheets("Sheet1")
For Each wksCopyFrom In Worksheets
If wksCopyFrom.Name < wksCopyTo.Name And _
wksCopyFrom.Name < "Sheet10" Then 'sheets you don't want searched
Set rngToSearch = wksCopyFrom.Cells
Set rngFound = rngToSearch.Find(txtFind.Text, _
, xlValues, xlWhole)
If Not rngFound Is Nothing Then
Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A"). _
End(xlUp).Offset(1, 0)
rngFound.EntireRow.Copy rngCopyTo
End If
End If
Next wksCopyFrom
End Sub
--
HTH...

Jim Thomlinson


"Mark Cover" wrote:

Thanks so much for your reply Jim. This is working but i still have a need
to past all of the contents of the row from which the cell was found. also i
would like to be able to search the entire workbook that contains 9 sheets,
and paste it in sheet 1. Thanks so much for your help.
-Mark

"Jim Thomlinson" wrote:

Here is some code that should work for you. I did not know where you wnated
the item pasted (paste regular or paste special for that matter) so I pasted
regular in the first blank cell in column a on the destination sheet. It is
important when doing a find to handle the case when it is not found. I just
did a message back to the user...

Private Sub cmdFind_Click()
Dim wksCopyFrom As Worksheet
Dim wksCopyTo As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngCopyTo As Range

Set wksCopyFrom = Sheets("Sheet1")
Set rngToSearch = wksCopyFrom.Cells
Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, xlWhole)
If rngFound Is Nothing Then
MsgBox "That item was not found."
Else
Set wksCopyTo = Sheets("Sheet2")
Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(1,
0)
rngFound.Copy rngCopyTo
End If

End Sub
--
HTH...

Jim Thomlinson


"Mark Cover" wrote:

Here is the problem. I am not able to get the info to paste into sheet1. I
can use the find function to find the cell but not able to paste. I would
also like to mention that I have multiple text boxes to search from. If
anyone can help i would greatly appreciate it. Thanks
-mark
Private Sub cmdFind_Click()
Dim R As Range
Dim Sheet As Worksheet
Sheets("sheet1").Select
Sheets("Sheet2").Select
Cells.Find(What:=txtFind.Text, After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Fiind from textbox and paste into sheet1

Jim,
IT WORKS GREAT!! Thanks for all of your help. I have been at this
for a while now. I am still a newbie. Thanks so much...
Mark

"Jim Thomlinson" wrote:

The best way to search all of the sheets depends on how many sheets you do
not want to search. Obviously you do not want to search the sheet you are
pasting to. You will also need to specify any other sheets that need to be
excluded in this code

Private Sub cmdFind_Click()
Dim wksCopyFrom As Worksheet
Dim wksCopyTo As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngCopyTo As Range

Set wksCopyTo = Sheets("Sheet1")
For Each wksCopyFrom In Worksheets
If wksCopyFrom.Name < wksCopyTo.Name And _
wksCopyFrom.Name < "Sheet10" Then 'sheets you don't want searched
Set rngToSearch = wksCopyFrom.Cells
Set rngFound = rngToSearch.Find(txtFind.Text, _
, xlValues, xlWhole)
If Not rngFound Is Nothing Then
Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A"). _
End(xlUp).Offset(1, 0)
rngFound.EntireRow.Copy rngCopyTo
End If
End If
Next wksCopyFrom
End Sub
--
HTH...

Jim Thomlinson


"Mark Cover" wrote:

Thanks so much for your reply Jim. This is working but i still have a need
to past all of the contents of the row from which the cell was found. also i
would like to be able to search the entire workbook that contains 9 sheets,
and paste it in sheet 1. Thanks so much for your help.
-Mark

"Jim Thomlinson" wrote:

Here is some code that should work for you. I did not know where you wnated
the item pasted (paste regular or paste special for that matter) so I pasted
regular in the first blank cell in column a on the destination sheet. It is
important when doing a find to handle the case when it is not found. I just
did a message back to the user...

Private Sub cmdFind_Click()
Dim wksCopyFrom As Worksheet
Dim wksCopyTo As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngCopyTo As Range

Set wksCopyFrom = Sheets("Sheet1")
Set rngToSearch = wksCopyFrom.Cells
Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, xlWhole)
If rngFound Is Nothing Then
MsgBox "That item was not found."
Else
Set wksCopyTo = Sheets("Sheet2")
Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(1,
0)
rngFound.Copy rngCopyTo
End If

End Sub
--
HTH...

Jim Thomlinson


"Mark Cover" wrote:

Here is the problem. I am not able to get the info to paste into sheet1. I
can use the find function to find the cell but not able to paste. I would
also like to mention that I have multiple text boxes to search from. If
anyone can help i would greatly appreciate it. Thanks
-mark
Private Sub cmdFind_Click()
Dim R As Range
Dim Sheet As Worksheet
Sheets("sheet1").Select
Sheets("Sheet2").Select
Cells.Find(What:=txtFind.Text, After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate



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
How to copy from sheet1 then paste special transpose to sheet2,3,4 Christine Excel Discussion (Misc queries) 2 July 22nd 09 09:50 PM
Macro to Copy data from a list in sheet1 and paste into sheet2 Michael Excel Discussion (Misc queries) 3 April 23rd 08 06:52 PM
Find Text from textBox then past what is found on sheet1 Mark Cover Excel Programming 1 October 5th 05 04:58 PM
Auto-lookup values between Sheet3 & UserForm & paste to Sheet1 duBedat68 Excel Programming 2 December 22nd 04 01:37 PM
Search, find, copy from sheet1 and paste into sheet2 lothario[_47_] Excel Programming 4 November 9th 03 09:07 AM


All times are GMT +1. The time now is 11:01 PM.

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"