LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default For loop question

Good morning or evening! I want to change the iLastRow when the rows are inserted. However, the loop ends when i = 22, even though the iLastRow is actually changed to 29 for example. Please advise me what is wrong here. Thanks

iLastRow = 2

For i = iRow To iLastRo
Set oCell = ws.Cells(i, iCol
Set nextCell = oCell.Offset(1, 0
If nextCell.Value < "" The
iDiff = DateDiff("m", oCell.Value, nextCell.Value
If iDiff 1 The
Set rngInsert = ws.Range(Cells(i + 1, iCol), Cells(i + iDiff - 1, iLastCol)
rngInsert.Selec
Selection.Insert Shift:=xlDow
'i + iDiff -
ws.Cells(i + 1, iCol).Value = DateAdd("m", 1, oCell
'Fill dow
ws.Range(Cells(i, iCol), Cells(i + 1, iCol)).Selec
Selection.AutoFill Destination:=ws.Range(Cells(i, iCol), Cells(i + iDiff - 1, iCol)), Type:=xlFillDefaul

ws.Range(Cells(i + 1, iLastCol), Cells(i + iDiff - 1, iLastCol)).Value =
'Increase
i = i + iDif
iLastRow = WorksheetFunction.CountA(ws.Columns(iCol)
End I
End I
Next i
 
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
Loop question aelewis Excel Discussion (Misc queries) 2 October 24th 07 08:12 PM
Loop question N.F[_2_] Excel Discussion (Misc queries) 0 July 12th 07 08:02 PM
Password Loop question. Andy Tallent Excel Discussion (Misc queries) 1 April 8th 05 01:16 PM
For Loop and If Statement question jacqui[_2_] Excel Programming 0 February 13th 04 04:17 PM
Another loop & sheet question steve Excel Programming 4 November 25th 03 02:12 PM


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