Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Reading Rows of Variable Length

Working in Excel 2003

I am trying to read the contents of cells in a row of variable length
offset by the contents of cell C2 and write the contents to Sheet 2
starting at cell C2.

I have written the following procedure to accomplish the task:

Sub CopyProcedure()
Dim I As Integer
I = 2

Do
With Worksheets("Sheet1").Cells(I, 2)
.Range(.Cells(1), _
.End(xlToRight)).Copy Destination:=Worksheets("Sheet2").Cells(I,
2)
I = I + 1
End With
Loop While Worksheets("Sheet1").Cells(I, 2).Value < ""
End Sub

The problem:
The procedure is reading and writing the next row down from the
initial offset cell (C2). Thereafter, in the looping process it reads
and writes the contents of the second row after the row just written.

How do I get the procedure to read and write every row?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Reading Rows of Variable Length

Here's an alternative

Dim I As Integer
I = 2

Do
With Worksheets("Sheet1").Cells(I, 3)
.Resize(1, .End(xlToRight).Column - .Column).Copy _
Destination:=Worksheets("Sheet2").Cells(I, 3)
I = I + 1
End With
Loop While Worksheets("Sheet1").Cells(I, 3).Value < ""


--

HTH

RP
(remove nothere from the email address if mailing direct)


"DCondie" wrote in message
om...
Working in Excel 2003

I am trying to read the contents of cells in a row of variable length
offset by the contents of cell C2 and write the contents to Sheet 2
starting at cell C2.

I have written the following procedure to accomplish the task:

Sub CopyProcedure()
Dim I As Integer
I = 2

Do
With Worksheets("Sheet1").Cells(I, 2)
.Range(.Cells(1), _
.End(xlToRight)).Copy Destination:=Worksheets("Sheet2").Cells(I,
2)
I = I + 1
End With
Loop While Worksheets("Sheet1").Cells(I, 2).Value < ""
End Sub

The problem:
The procedure is reading and writing the next row down from the
initial offset cell (C2). Thereafter, in the looping process it reads
and writes the contents of the second row after the row just written.

How do I get the procedure to read and write every row?



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
sumproduct - reading a variable value redneck joe Excel Discussion (Misc queries) 3 May 24th 06 08:02 PM
Counting Variable Length of Rows in a Named Range jandre[_2_] Excel Programming 0 October 28th 04 06:26 PM
Counting Variable Length of Rows in a Named Range jandre[_3_] Excel Programming 0 October 28th 04 06:24 PM
Counting Variable Length of Rows in a Named Range jandre Excel Programming 1 October 28th 04 05:27 PM
Reading Textfile into a variable Seth[_3_] Excel Programming 1 April 11th 04 08:46 PM


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