Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy rows and count


Hi,

New to this forum and new to Excel VBA ;-)
This is my problem:
I have a worksheet with five columns, the first has values ending wit
numbers "01". I want to copy the rows, one by one, to anothe
worksheet, 20 times, with the first column incrementing from "01" t
"20". Then the next row with the same incrementing and so on, until th
end of the range.

Regards,
Ralph Utbul

--
mud
-----------------------------------------------------------------------
mudd's Profile: http://www.excelforum.com/member.php...fo&userid=3490
View this thread: http://www.excelforum.com/showthread.php?threadid=54640

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy rows and count


Try something like

Sub Test()
Set DataRange = Range(Cells(1, 1), Cells(100, 1))
For Each Cell In DataRange
For N = 1 To 20
Sheets("Sheet2").Cells(65536, 1).End(xlUp).Offset(1, 0) =
Left(Cell, Len(Cell) - 2) & Left("00", 2 - Len(N)) & N
Range(Cells(Cell.Row, 2), Cells(Cell.Row, Cells(Cell.Row,
256).End(xlToLeft).Column)).Copy
Destination:=Sheets("Sheet2").Cells(65536, 1).End(xlUp).Offset(0, 1)
Next N
Next Cell
End Sub

This will create a list on the second sheet with the 20 values stacked
beneath each other. I assume that this is what you wanted.


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=546400

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy rows and count


mrice Wrote:
Try something like


Range(Cells(Cell.Row, 2), Cells(Cell.Row, Cells(Cell.Row,
256).End(xlToLeft).Column)).Copy
Destination:=Sheets("Sheet2").Cells(65536, 1).End(xlUp).Offset(0, 1)

This will create a list on the second sheet with the 20 values stacked
beneath each other. I assume that this is what you wanted.


Thanks!
It worked great, with a small amount of customization, of course ;-)
I narrowed the area that gets copied:
Range(Cells(Cell.Row, 14), Cells(Cell.Row, 18)).Copy
destination:=Sheets("Sheet2").Cells(65536, 1).End(xlUp).Offset(0, 1)

My code has cut time from two hours to 5 minutes and gotten rid of the
mistakes involved in tedious, repititive work. I'm really happy about
this!

Regards,
Ralph


--
mudd
------------------------------------------------------------------------
mudd's Profile: http://www.excelforum.com/member.php...o&userid=34902
View this thread: http://www.excelforum.com/showthread...hreadid=546400

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
count count multiple rows Lise Excel Discussion (Misc queries) 5 December 18th 08 04:41 AM
Count all rows in column with data, Except rows 1-5 Gregory Day Excel Worksheet Functions 4 March 27th 08 02:58 PM
Count number of rows, where non relevant rows are hidden Pieter Excel Discussion (Misc queries) 2 November 8th 06 12:24 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM
Why does rngDataSource.Rows.Count = 65536 when worksheet Rows=95? [email protected] Excel Discussion (Misc queries) 12 July 22nd 05 12:50 PM


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