Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change the code to copy whole row

What do i need to change in this piece of code so it copies the whol
row and not just the first column of the row?

Sub movedata()
Dim i As Integer
Dim x As Integer
Dim mySheet As Integer
Dim mySheetRow As Integer

i = 1
While Cells(i, 1) ""
x = Cells(i, 1).Row Mod 8
If x = 1 Then
mySheet = 1
mySheetRow = mySheetRow + 1
If mySheetRow = 0 Then mySheetRow = 8
Else
mySheet = mySheet + 1
End If
Worksheets(mySheet + 1).Cells(mySheetRow, 1) = Cells(i, 1)
i = i + 1
Wend
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Change the code to copy whole row

Hi Paul,

Change

Worksheets(mySheet + 1).Cells(mySheetRow, 1) = Cells(i, 1)

to

Cells(i, 1).Entirerow.Copy Worksheets(mySheet + 1).Cells(mySheetRow, 1)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"pauluk " wrote in message
...
What do i need to change in this piece of code so it copies the whole
row and not just the first column of the row?

Sub movedata()
Dim i As Integer
Dim x As Integer
Dim mySheet As Integer
Dim mySheetRow As Integer

i = 1
While Cells(i, 1) ""
x = Cells(i, 1).Row Mod 8
If x = 1 Then
mySheet = 1
mySheetRow = mySheetRow + 1
If mySheetRow = 0 Then mySheetRow = 8
Else
mySheet = mySheet + 1
End If
Worksheets(mySheet + 1).Cells(mySheetRow, 1) = Cells(i, 1)
i = i + 1
Wend
End Sub


---
Message posted from http://www.ExcelForum.com/



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
Copy code Hamster07 New Users to Excel 4 January 30th 07 05:08 PM
copy and use vba code Giz New Users to Excel 6 November 24th 06 11:39 PM
copy and use vba code Giz Excel Discussion (Misc queries) 9 November 22nd 06 09:57 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
Copy Sheets minus Worksheet Change Event code & Macro Buttons Bob[_36_] Excel Programming 0 October 8th 03 01:17 AM


All times are GMT +1. The time now is 11:35 AM.

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"