Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Search for values in a sheet and copy found records one after theother in another sheet

Dear Experts:

Below macro ...
(1)... creates a user-defined search dialog box and ...
(2)... searches for data records that are listed in a
'xlsheetveryhidden'-worksheet (Sheet name = list)... and
(3)... if found, the data record is copied into the active cell of the
current worksheet.

I would like to have this macro rewritten so that ...
.... Excel copies the first instance of a found value/data record right
into row 1 of the current worksheet. Subsequent hits should then be
copied into row 2, row 3 etc. and so forth no matter which cell is
activated.

Is this possible? Help is very much appreciated. Thank you very much
in advance.

Regards, Andreas


Sub Find_it_and_copy_it()
Dim varWhat
Dim rngfound As Range
varWhat = Application.InputBox("Enter text to find")
Set rngfound = Sheets("list").Cells.Find(what:=varWhat,
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
If Not rngfound Is Nothing Then
rngfound.EntireRow.Copy Cells(ActiveCell.Row, 1)
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Search for values in a sheet and copy found records one after theother in another sheet

On 14 Jun., 09:55, AndreasHermle
wrote:
Dear Experts:

Below macro ...
(1)... creates a user-defined search dialog box and ...
(2)... searches for data records that are listed in a
'xlsheetveryhidden'-worksheet (Sheet name = list)... and
(3)... if found, the data record is copied into the active cell of the
current worksheet.

I would like to have this macro rewritten so that ...
... Excel copies the first instance of a found value/data record right
into row 1 of the current worksheet. Subsequent hits should then be
copied into row 2, row 3 etc. and so forth no matter which cell is
activated.

Is this possible? Help is very much appreciated. Thank you very much
in advance.

Regards, Andreas

Sub Find_it_and_copy_it()
* *Dim varWhat
* *Dim rngfound As Range
* *varWhat = Application.InputBox("Enter text to find")
* *Set rngfound = Sheets("list").Cells.Find(what:=varWhat,
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
* *If Not rngfound Is Nothing Then
* * * rngfound.EntireRow.Copy Cells(ActiveCell.Row, 1)
* *End If
End Sub


This should do it:

Sub Find_it_and_copy_it()
Dim varWhat
Dim rngFound As Range
Dim R As Long
Dim fFound As Range

varWhat = Application.InputBox("Enter text to find")
Set rngFound = Sheets("list").Cells.Find(what:=varWhat, _
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
Set fFound = rngFound
If Not rngFound Is Nothing Then
Do
R = R + 1
rngFound.EntireRow.Copy Cells(R, 1)
Set rngFound = Sheets("list").Cells.FindNext(after:=rngFound)
Loop Until rngFound.Address = fFound.Address
End If
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Search for values in a sheet and copy found records one after theother in another sheet

On 15 Jun., 16:05, Per Jessen wrote:
On 14 Jun., 09:55, AndreasHermle
wrote:





Dear Experts:


Below macro ...
(1)... creates a user-defined search dialog box and ...
(2)... searches for data records that are listed in a
'xlsheetveryhidden'-worksheet (Sheet name = list)... and
(3)... if found, the data record is copied into the active cell of the
current worksheet.


I would like to have this macro rewritten so that ...
... Excel copies the first instance of a found value/data record right
into row 1 of the current worksheet. Subsequent hits should then be
copied into row 2, row 3 etc. and so forth no matter which cell is
activated.


Is this possible? Help is very much appreciated. Thank you very much
in advance.


Regards, Andreas


Sub Find_it_and_copy_it()
* *Dim varWhat
* *Dim rngfound As Range
* *varWhat = Application.InputBox("Enter text to find")
* *Set rngfound = Sheets("list").Cells.Find(what:=varWhat,
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
* *If Not rngfound Is Nothing Then
* * * rngfound.EntireRow.Copy Cells(ActiveCell.Row, 1)
* *End If
End Sub


This should do it:

Sub Find_it_and_copy_it()
* *Dim varWhat
* *Dim rngFound As Range
* *Dim R As Long
* *Dim fFound As Range

* *varWhat = Application.InputBox("Enter text to find")
* *Set rngFound = Sheets("list").Cells.Find(what:=varWhat, _
* * * * LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
* *Set fFound = rngFound
* *If Not rngFound Is Nothing Then
* * * Do
* * * * R = R + 1
* * * * rngFound.EntireRow.Copy Cells(R, 1)
* * * * Set rngFound = Sheets("list").Cells.FindNext(after:=rngFound)
* * Loop Until rngFound.Address = fFound.Address
End If
End Sub- Zitierten Text ausblenden -

- Zitierten Text anzeigen -


Hi Per,

thank you very much for your quick support. I am afraid to tell you
that the code keeps writing all the found values right into A1, i.e.
overwriting the values over and over.
Any idea why?

Regards, Andreas
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Search for values in a sheet and copy found records one after theother in another sheet

On 15 Jun., 16:52, AndreasHermle
wrote:
On 15 Jun., 16:05, Per Jessen wrote:





On 14 Jun., 09:55, AndreasHermle
wrote:


Dear Experts:


Below macro ...
(1)... creates a user-defined search dialog box and ...
(2)... searches for data records that are listed in a
'xlsheetveryhidden'-worksheet (Sheet name = list)... and
(3)... if found, the data record is copied into the active cell of the
current worksheet.


I would like to have this macro rewritten so that ...
... Excel copies the first instance of a found value/data record right
into row 1 of the current worksheet. Subsequent hits should then be
copied into row 2, row 3 etc. and so forth no matter which cell is
activated.


Is this possible? Help is very much appreciated. Thank you very much
in advance.


Regards, Andreas


Sub Find_it_and_copy_it()
* *Dim varWhat
* *Dim rngfound As Range
* *varWhat = Application.InputBox("Enter text to find")
* *Set rngfound = Sheets("list").Cells.Find(what:=varWhat,
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
* *If Not rngfound Is Nothing Then
* * * rngfound.EntireRow.Copy Cells(ActiveCell.Row, 1)
* *End If
End Sub


This should do it:


Sub Find_it_and_copy_it()
* *Dim varWhat
* *Dim rngFound As Range
* *Dim R As Long
* *Dim fFound As Range


* *varWhat = Application.InputBox("Enter text to find")
* *Set rngFound = Sheets("list").Cells.Find(what:=varWhat, _
* * * * LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
* *Set fFound = rngFound
* *If Not rngFound Is Nothing Then
* * * Do
* * * * R = R + 1
* * * * rngFound.EntireRow.Copy Cells(R, 1)
* * * * Set rngFound = Sheets("list").Cells.FindNext(after:=rngFound)
* * Loop Until rngFound.Address = fFound.Address
End If
End Sub- Zitierten Text ausblenden -


- Zitierten Text anzeigen -


Hi Per,

thank you very much for your quick support. I am afraid to tell you
that the code keeps writing all the found values right into A1, i.e.
overwriting the values over and over.
Any idea why?

Regards, Andreas- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -


Hi Andreas,

It sounds very strange!

I just tested the code and it pasted each hit to a new row, always
starting from row 1 when I start a new search. Are you sure, that
there is more than one match in the 'List' sheet?

Regards, Per
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default Search for values in a sheet and copy found records one after the other in another sheet

I also tested Per's code and it worked as advertised.


Gord Dibben MS Excel MVP

On Wed, 15 Jun 2011 11:04:33 -0700 (PDT), Per Jessen
wrote:

Hi Andreas,

It sounds very strange!

I just tested the code and it pasted each hit to a new row, always
starting from row 1 when I start a new search. Are you sure, that
there is more than one match in the 'List' sheet?

Regards, Per



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Search for values in a sheet and copy found records one after theother in another sheet

On 15 Jun., 21:06, Gord Dibben wrote:
I also tested Per's code and it worked as advertised.

Gord Dibben * * MS Excel MVP

On Wed, 15 Jun 2011 11:04:33 -0700 (PDT), Per Jessen
wrote:



Hi Andreas,


It sounds very strange!


I just tested the code and it pasted each hit to a new row, always
starting from row 1 when I start a new search. Are you sure, that
there is more than one match in the 'List' sheet?


Regards, Per- Zitierten Text ausblenden -


- Zitierten Text anzeigen -



Dear Gord and Per,

thank you very much for your support. This is really strange. These
are the sample values in the 'list'-sheet:
1754 Martin
1755 Gordon
1756 Jim
1757 Jones

On the other sheet of the same workbook I got a macro button linked to
your code.
Whenever I press it, I am prompted to enter text, I enter either 1754,
1755, 1756 or 1757. In case of entering 1754, the entire row, i.e.
1754 Martin is pasted into the very first row of the active
worksheet.
On running the macro again, I enter 1755 and the entire row, i.e. 1755
Gordon overwrites! the first entry, i.e. 1754 Martin and so forth.

Reading your code it makes absolute sense. I will try it on another
machine and then let you know.

Till then, Regards, Andreas
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
Delete values in sheet 2 that arre found in sheet 1 np Excel Discussion (Misc queries) 1 December 10th 09 07:21 PM
lookup single value in one sheet, return multiple results from theother sheet Chuck[_3_] Excel Worksheet Functions 1 April 4th 08 06:17 AM
Search for rows in one sheet and copy into another sheet based on customer id [email protected] Excel Worksheet Functions 1 October 22nd 07 03:09 AM
copy values generated by conditional formula in one sheet to the other work sheet as values ramana Excel Worksheet Functions 1 October 5th 05 01:04 PM
copy values generated by conditional formula in one sheet to the other work sheet as values bobby Excel Discussion (Misc queries) 1 October 5th 05 12:18 PM


All times are GMT +1. The time now is 11:54 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"