Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Copying selected rows into new worksheet

Good afternoon everyone, hope someone can help me with this

I have a worksheet that has blocks of transactions, with a summary
transaction for each one at the bottom of the block, and blank rows
seperating the different blocks of trades.

The blocks are seperated by date and product
-----------------------------------------------------------------------------------------------
EG:
Date Quantity BUY/SELL Price Gross Sale Currency Account Item
20090727 16997 S 5 84985 GBP DEFAULT Coke
20090727 48606 S 5 243030 GBP DEFAULT Coke
20090727 10000 S 5 50000 GBP DEFAULT Coke
20090727 58316 S 4 233264 GBP DEFAULT Coke
20090727 133919 S 19 233264 GBP DEFAULT Coke

20090727 9238 S 5 46190 GBP DEFAULT Pepsi
20090727 4146 S 6 24876 GBP DEFAULT Pepsi
20090727 13384 S 11 24876 GBP DEFAULT Pepsi

etc.
------------------------------------------------------------------------------------------------
I am trying to write a macro that finds the final row of each transaction
(which is a summary of the rows above it) and copies it to a new worksheet.

Will provide further explanation if needed

Really appreciate any advice you can provide

Regards,
PVANS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Copying selected rows into new worksheet

Try the below macro..which will copy the row just before blank row to Sheet2.

Sub MyMacro()
Dim lngRow As Long, lngNRow As Long
Dim ws2 As Worksheet
Set ws2 = Sheets("Sheet2")
lngNRow = 1

For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row + 1
If Trim(Range("A" & lngRow)) = "" Then
Rows(lngRow - 1).Copy ws2.Rows(lngNRow)
lngNRow = lngNRow + 1
End If
Next
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"PVANS" wrote:

Good afternoon everyone, hope someone can help me with this

I have a worksheet that has blocks of transactions, with a summary
transaction for each one at the bottom of the block, and blank rows
seperating the different blocks of trades.

The blocks are seperated by date and product
-----------------------------------------------------------------------------------------------
EG:
Date Quantity BUY/SELL Price Gross Sale Currency Account Item
20090727 16997 S 5 84985 GBP DEFAULT Coke
20090727 48606 S 5 243030 GBP DEFAULT Coke
20090727 10000 S 5 50000 GBP DEFAULT Coke
20090727 58316 S 4 233264 GBP DEFAULT Coke
20090727 133919 S 19 233264 GBP DEFAULT Coke

20090727 9238 S 5 46190 GBP DEFAULT Pepsi
20090727 4146 S 6 24876 GBP DEFAULT Pepsi
20090727 13384 S 11 24876 GBP DEFAULT Pepsi

etc.
------------------------------------------------------------------------------------------------
I am trying to write a macro that finds the final row of each transaction
(which is a summary of the rows above it) and copies it to a new worksheet.

Will provide further explanation if needed

Really appreciate any advice you can provide

Regards,
PVANS

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Copying selected rows into new worksheet

thanks Jacob,

it worked like a charm :)

Have a good day

Regards,

"Jacob Skaria" wrote:

Try the below macro..which will copy the row just before blank row to Sheet2.

Sub MyMacro()
Dim lngRow As Long, lngNRow As Long
Dim ws2 As Worksheet
Set ws2 = Sheets("Sheet2")
lngNRow = 1

For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row + 1
If Trim(Range("A" & lngRow)) = "" Then
Rows(lngRow - 1).Copy ws2.Rows(lngNRow)
lngNRow = lngNRow + 1
End If
Next
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"PVANS" wrote:

Good afternoon everyone, hope someone can help me with this

I have a worksheet that has blocks of transactions, with a summary
transaction for each one at the bottom of the block, and blank rows
seperating the different blocks of trades.

The blocks are seperated by date and product
-----------------------------------------------------------------------------------------------
EG:
Date Quantity BUY/SELL Price Gross Sale Currency Account Item
20090727 16997 S 5 84985 GBP DEFAULT Coke
20090727 48606 S 5 243030 GBP DEFAULT Coke
20090727 10000 S 5 50000 GBP DEFAULT Coke
20090727 58316 S 4 233264 GBP DEFAULT Coke
20090727 133919 S 19 233264 GBP DEFAULT Coke

20090727 9238 S 5 46190 GBP DEFAULT Pepsi
20090727 4146 S 6 24876 GBP DEFAULT Pepsi
20090727 13384 S 11 24876 GBP DEFAULT Pepsi

etc.
------------------------------------------------------------------------------------------------
I am trying to write a macro that finds the final row of each transaction
(which is a summary of the rows above it) and copies it to a new worksheet.

Will provide further explanation if needed

Really appreciate any advice you can provide

Regards,
PVANS

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
Copying selected rows to a new workbook Jeffrey Marks New Users to Excel 0 July 27th 11 03:51 PM
Copying only selected items to another worksheet firewaterjoe Excel Worksheet Functions 1 January 23rd 08 06:12 PM
Copying Selected Rows From Workbook1 to WorkBook2 [email protected] Excel Discussion (Misc queries) 0 October 10th 06 11:27 PM
Copying Selected Rows From Workbook1 to WorkBook2 [email protected] Excel Discussion (Misc queries) 0 October 10th 06 11:24 PM
Copying selected rows to another sheet tacarme Excel Worksheet Functions 3 June 25th 05 11:46 AM


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