Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Search then copy and past data

To all,

I have taken this code from the MS VBA Help File. How can I modify it
so that instead of changing the pattern of the cell, it instead copys
the entire row that the cell is in, and pastes it into another workbook
called test1.xls, sheet1, cell A2?

Thanks in advance,

Joseph Crabtree


With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search then copy and past data

The code you show is for finding multiple instances. If that is the case,
then I assume you wouldn't want subsequent found instances to be copied over
ones already copied

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
i = 0
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.entireRow.copy Worksheets("Test1.xls").Worksheets( _
"Sheet1").Range("A1")(i)
i = i + 1
Set c = .FindNext(c)
Loop While c.Address < firstAddress
End If
End With


--
Regards,
Tom Ogilvy



"joecrabtree" wrote in message
s.com...
To all,

I have taken this code from the MS VBA Help File. How can I modify it
so that instead of changing the pattern of the cell, it instead copys
the entire row that the cell is in, and pastes it into another workbook
called test1.xls, sheet1, cell A2?

Thanks in advance,

Joseph Crabtree


With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search then copy and past data

A couple of typos: It should be:

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
i = 1
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.entireRow.copy Worksheets("Test1.xls").Worksheets( _
"Sheet1").Range("A2")(i)
i = i + 1
Set c = .FindNext(c)
Loop While c.Address < firstAddress
End If
End With

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
The code you show is for finding multiple instances. If that is the case,
then I assume you wouldn't want subsequent found instances to be copied
over ones already copied

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
i = 0
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.entireRow.copy Worksheets("Test1.xls").Worksheets( _
"Sheet1").Range("A1")(i)
i = i + 1
Set c = .FindNext(c)
Loop While c.Address < firstAddress
End If
End With


--
Regards,
Tom Ogilvy



"joecrabtree" wrote in message
s.com...
To all,

I have taken this code from the MS VBA Help File. How can I modify it
so that instead of changing the pattern of the cell, it instead copys
the entire row that the cell is in, and pastes it into another workbook
called test1.xls, sheet1, cell A2?

Thanks in advance,

Joseph Crabtree


With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With





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
source data editor in Excel 2007 dont seem to allow copy and past. Pieter Charts and Charting in Excel 1 May 8th 08 12:35 AM
Macro to Copy/Paste Data into one wksht, skipp one row before past Shoney Excel Discussion (Misc queries) 1 February 22nd 08 01:28 AM
How to search my past question ? Eric Excel Worksheet Functions 1 March 30th 07 06:04 AM
Macro: Insert, copy and past data from sheet Metaldream7 Excel Discussion (Misc queries) 0 November 8th 06 09:31 PM
How do you copy and past data from one spreadsheet to another? trainer07 Excel Discussion (Misc queries) 1 August 9th 06 07:21 PM


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