Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 90
Default visual basic. find copy row past into new sheet

In visual basic

How do i find a row in sheet 1 which has "TEST" in colum K and then in sheet
2 find the next blank row and paste the hole row from sheet 1 into sheet 2.
there could be 100 rows that have "test" in.

Many thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default visual basic. find copy row past into new sheet

Perhaps use datafilterautofilterfilter the column with test by
testcopypaste to the other sheet row. Record a macro while doing and then
modify to find the last row by using something like.

lastrow=sheets("sheet2").cells(rows.count,"a").end (xlup).row+1
range("yourfilteredrange").copy sheets("sheet2").cells(lastrow,"a")

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Chuck" wrote in message
...
In visual basic

How do i find a row in sheet 1 which has "TEST" in colum K and then in
sheet
2 find the next blank row and paste the hole row from sheet 1 into sheet
2.
there could be 100 rows that have "test" in.

Many thanks


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default visual basic. find copy row past into new sheet

Maybe this in a module

Sub copyit()
Dim MyRange, MyRange1 As Range
Sheets("Sheet1").Select
LastRow = Sheets("Sheet1").Range("K65536").End(xlUp).Row
Set MyRange = Sheets("Sheet1").Range("K1:K" & LastRow)
For Each c In MyRange
If c.Value = "Test" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
MyRange1.Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub


Mike

"Chuck" wrote:

In visual basic

How do i find a row in sheet 1 which has "TEST" in colum K and then in sheet
2 find the next blank row and paste the hole row from sheet 1 into sheet 2.
there could be 100 rows that have "test" in.

Many thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 90
Default visual basic. find copy row past into new sheet

Many thanks for the help...... i keep getting errors!!!!!!!
I get: "Object variable or With block variable not set" or "Error 91", i
then de-bug, MyRange1.Select
i also can't find out how to loop this around to keep searching paste into
the first free space on sheet 2

Sorry new to all this......


"Mike H" wrote:

Maybe this in a module

Sub copyit()
Dim MyRange, MyRange1 As Range
Sheets("Sheet1").Select
LastRow = Sheets("Sheet1").Range("K65536").End(xlUp).Row
Set MyRange = Sheets("Sheet1").Range("K1:K" & LastRow)
For Each c In MyRange
If c.Value = "Test" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
MyRange1.Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub


Mike

"Chuck" wrote:

In visual basic

How do i find a row in sheet 1 which has "TEST" in colum K and then in sheet
2 find the next blank row and paste the hole row from sheet 1 into sheet 2.
there could be 100 rows that have "test" in.

Many thanks

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
If match copy cells in visual basic. thomsonpa New Users to Excel 3 December 13th 07 05:14 PM
copy and paste (visual basic) ian123 New Users to Excel 1 June 8th 06 12:22 AM
visual basic (copy and paste) ian123 Excel Worksheet Functions 2 June 7th 06 11:26 PM
microsoft visual basic compile error can't find library mamabuff Setting up and Configuration of Excel 1 December 29th 05 11:19 AM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM


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