LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 21
Default loop error

i have this code :

sub test()
Dim j As Integer
Dim i As Integer
Dim x As Integer
Dim rng1 As Range
Dim rng2 As Range

Sheets("sheet2").Select
Range("A1:Z500").Select
Selection.ClearContents

Set rng1 = Worksheets("sheet1").Range("A1")
Set rng2 = Worksheets("sheet2").Range("A1")

x = rng1.CurrentRegion.Rows.Count - 1
For j = 0 To x
For i = 0 To x
rng2.Offset(j, i) = rng1.Offset(j, 0)
Next i
Next j
For j = 0 To x
rng2.Offset(j, j) = rng1.Offset(j, 0) + 0.1
Next j

End Sub

Sub ProcessData()
Dim i As Integer, Cols As Integer

'move Sheet1 ColA to safe place
Sheets("Sheet1").Activate
[AA:AA].Value = [A:A].Value
'...determine # of loops
Sheets("Sheet2").Activate
Cols = ActiveSheet.UsedRange.Columns.Count

'Start looping

For i = 1 To Cols
'...select Col i from Sheet2, paste to Sheet1 ColA
Columns(i).Copy
Sheets("Sheet1").Columns(1).PasteSpecial
'...Copy Sheet3 Row 1 to Row i in Sheet 4
Sheets("Sheet4").Rows(i).Value = Sheets("Sheet3").Rows(1).Value
Next i

'Restore Sheet1 ColA
Sheets("Sheet1").Activate
[A:A].Value = [AA:AA].Value
End Sub



-----------------------------------

i m having an error on sheet 4..
its giving me the right answer but afer that ..
its giving me lots of columns and rows of zeros and numerical data ..

its abt 35 rows...
why is this



can some one help with code...


is somthg misssing ?

sam
 
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
stuck in an error loop Darla Excel Discussion (Misc queries) 1 January 8th 10 06:06 PM
loop code error help!!!! cesaoes Excel Discussion (Misc queries) 2 January 29th 08 04:52 PM
Error on second pass of loop. Rob Excel Discussion (Misc queries) 1 September 9th 05 07:26 PM
error on second pass of loop. Rob Excel Discussion (Misc queries) 3 September 9th 05 07:01 PM
loop error Sam Excel Programming 1 September 18th 03 03:09 PM


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