Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default find, copy and paste

Hi,

Can someone show me how write a macro that is doing the following;

find a text
select the cells
copy it
paste into another sheet

What is does right now is the following;
find a text
select the cells (A1:B1)
copy it
and past it

But the problem is that the next time the text is located somewhere
else, e.q. A10:B10

So how can I copy this text without setting the cells in the macro?

Reg. Patrick.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default find, copy and paste

Hi Patrick,

Have a look at Ron De Bruin's web site:

http://www.rondebruin.nl/copy2.htm

Dan

On Oct 3, 4:51 pm, Patrick wrote:
Hi,

Can someone show me how write a macro that is doing the following;

find a text
select the cells
copy it
paste into another sheet

What is does right now is the following;
find a text
select the cells (A1:B1)
copy it
and past it

But the problem is that the next time the text is located somewhere
else, e.q. A10:B10

So how can I copy this text without setting the cells in the macro?

Reg. Patrick.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default find, copy and paste

A little clarification. Ron's site doesn't show the syntax of the copy
statement. The general form is

OldRange.copy Destination:=NewRange

The word "Destination" is not required, but it makes the code easy for
novices to understand.

"dan dungan" wrote:

Hi Patrick,

Have a look at Ron De Bruin's web site:

http://www.rondebruin.nl/copy2.htm

Dan

On Oct 3, 4:51 pm, Patrick wrote:
Hi,

Can someone show me how write a macro that is doing the following;

find a text
select the cells
copy it
paste into another sheet

What is does right now is the following;
find a text
select the cells (A1:B1)
copy it
and past it

But the problem is that the next time the text is located somewhere
else, e.q. A10:B10

So how can I copy this text without setting the cells in the macro?

Reg. Patrick.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default find, copy and paste

On Thu, 04 Oct 2007 00:00:16 -0000, dan dungan
wrote:

Hi Patrick,

Have a look at Ron De Bruin's web site:

http://www.rondebruin.nl/copy2.htm

Dan

On Oct 3, 4:51 pm, Patrick wrote:
Hi,

Can someone show me how write a macro that is doing the following;

find a text
select the cells
copy it
paste into another sheet

What is does right now is the following;
find a text
select the cells (A1:B1)
copy it
and past it

But the problem is that the next time the text is located somewhere
else, e.q. A10:B10

So how can I copy this text without setting the cells in the macro?

Reg. Patrick.



I did, but it's not helping me ...
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default find, copy and paste

Patrick

From your post it looks like you want to find a string and copy the

string and the cell adjacent to this string, so two cells. This can
be modified to suit.

Good luck

Chad

Sub FindIt()
Dim MyString As String

MyString = InputBox("Find what?")
'Find the string in the inputbox
Cells.Find(What:=MyString, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate
'Sets the cells copied to 2, pastes the data as well.
ActiveCell.Resize(1, 2).Copy Sheets("sheet3").Range("A1")

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default find, copy and paste

On Thu, 04 Oct 2007 00:53:06 -0000, Chad
wrote:

Patrick

From your post it looks like you want to find a string and copy the

string and the cell adjacent to this string, so two cells. This can
be modified to suit.

Good luck

Chad

Sub FindIt()
Dim MyString As String

MyString = InputBox("Find what?")
'Find the string in the inputbox
Cells.Find(What:=MyString, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate
'Sets the cells copied to 2, pastes the data as well.
ActiveCell.Resize(1, 2).Copy Sheets("sheet3").Range("A1")

End Sub


Ok, this works.
Is it also possible to create a function for this one?

So, in the macro, i call this function with 3 values;
The searchstring, sheet and pastecell

e.q. "String", "sheet3", C4

Reg. Patrick.

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
Find-Copy and Paste Tasha Excel Programming 4 August 21st 07 09:18 PM
Find Copy Paste [email protected] Excel Programming 1 July 3rd 07 03:00 PM
Find/Copy/paste.. then Find/Paste - not working ... at all.... [email protected] Excel Programming 9 November 30th 06 08:49 PM
Find Copy and Paste RigasMinho Excel Programming 4 July 17th 06 09:32 PM


All times are GMT +1. The time now is 08:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"