Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying entire row


This was a code which was given to me yesterday by Nick. This copyes the
data of one sheet in different tabs. But this applies to first column
only. How to copy the entire row instead of only column a?

Dim StartBlock As Range
Dim CopyBlock As Range
Dim NewWS As Worksheet

With ActiveSheet
'Assuming start is in A1
Set StartBlock = .Range("A1")
'If this blank, we need the first non-blank cell
'If StartBlock.Value = "" Then Set StartBlock =
..Range(StartBlock.End(xlDown).Address)
If StartBlock.Value = "" Then Set StartBlock =
..Range(StartBlock.Address & ":" & StartBlock.End(xlDown).Address)

'Don't hard the Max Rows as Excel 12 etc will have 65K rows
Do Until StartBlock.Row = .Rows.Count

'Get the next block, before the next blank row
Set CopyBlock = .Range(StartBlock.Address & ":" &
StartBlock.End(xlDown).Address)

'Uncomment to see the Range that will be copied
'.Select
'CopyBlock.Select

'Create new WS at the end
Set NewWS = ThisWorkbook.Worksheets.Add(,
ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Co unt))

'Assuming each block goes to A1
CopyBlock.Copy NewWS.Range("A1")

'Move StartBlock to the end of the CopyBlock
Set StartBlock = .Range(StartBlock.End(xlDown).Address)
'Now move to the start of the next block
Set StartBlock = .Range(StartBlock.End(xlDown).Address)
Loop
End With


--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile: http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=500491

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Copying entire row

Sylvia,

Set CopyBlock = .Range(StartBlock.Address & ":" &
StartBlock.End(xlDown).Address).EntireRow

NickHK

"Sylvia" wrote in
message ...

This was a code which was given to me yesterday by Nick. This copyes the
data of one sheet in different tabs. But this applies to first column
only. How to copy the entire row instead of only column a?

Dim StartBlock As Range
Dim CopyBlock As Range
Dim NewWS As Worksheet

With ActiveSheet
'Assuming start is in A1
Set StartBlock = .Range("A1")
'If this blank, we need the first non-blank cell
'If StartBlock.Value = "" Then Set StartBlock =
Range(StartBlock.End(xlDown).Address)
If StartBlock.Value = "" Then Set StartBlock =
Range(StartBlock.Address & ":" & StartBlock.End(xlDown).Address)

'Don't hard the Max Rows as Excel 12 etc will have 65K rows
Do Until StartBlock.Row = .Rows.Count

'Get the next block, before the next blank row
Set CopyBlock = .Range(StartBlock.Address & ":" &
StartBlock.End(xlDown).Address)

'Uncomment to see the Range that will be copied
'.Select
'CopyBlock.Select

'Create new WS at the end
Set NewWS = ThisWorkbook.Worksheets.Add(,
ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Co unt))

'Assuming each block goes to A1
CopyBlock.Copy NewWS.Range("A1")

'Move StartBlock to the end of the CopyBlock
Set StartBlock = .Range(StartBlock.End(xlDown).Address)
'Now move to the start of the next block
Set StartBlock = .Range(StartBlock.End(xlDown).Address)
Loop
End With


--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile:

http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=500491



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 entire worksheets Todd Nelson Excel Discussion (Misc queries) 2 August 31st 05 06:50 PM
Copying an entire row of formulas Lazer[_4_] Excel Programming 2 August 11th 04 08:12 PM
Copying an Entire row using an IF Statement Marcus Excel Programming 1 July 6th 04 06:31 AM
Copying an Entire row using an IF Statement Marcus Excel Programming 2 July 5th 04 03:19 PM
Macro for copying entire raw Mac[_5_] Excel Programming 3 November 13th 03 03:09 AM


All times are GMT +1. The time now is 08:36 AM.

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"