Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel 2007 for next loop bug

The below routine now works just fine, but if I replace the first line with
two lines as follows , the For I1 = 7 to vbr Step 3 loop below starts out
with I1 set to the value of vbr every time. It took a while to find the work
around, but now it works fine. I'm wondering if there are other for-next
issues lurking out there that I need to be aware of.

Anyway, if I replace the first executable line in the routine below with the
following two lines, it consistently fails as described above. Replacing
those two lines with the equivalent one line, makes it work normally with I1
being set to 7 the first time thru the loop.

sname = ActiveSheet.Name
LastChar = right(sname,2)

Sub HideUnHideClosedLegs()
LastChar = Right(ActiveSheet.Name, 2)
If IsNumeric(LastChar) Then
HideFlag = Cells(2, 1).Value
If HideFlag = "H" Then
R1 = "7:60000"
Rows(R1).Select
Selection.EntireRow.Hidden = False
HideFlag = ""
Cells(2, 1).Value = HideFlag
Exit Sub
Else
HideFlag = "H"
Cells(2, 1).Value = HideFlag
End If
Call ReturnBottomRow(vBottomRow)
vbr1 = vBottomRow + 0
For i1 = 7 To vbr1 Step 3
i = i1
OpenFlag = Cells(i, 1).Value
If OpenFlag = 0 Then
j = i + 2
R1 = i & ":" & j
Rows(R1).Select
Selection.EntireRow.Hidden = True
End If
Next i1
Else
msg = "blah blah blah."
mtitle = "blah blah blah."
x = MsgBox(msg, vbOKOnly, mtitle)
End If
End Sub

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
excel 2007 recovery loop Michal Kaminski Setting up and Configuration of Excel 0 April 7th 10 11:11 AM
Breaking out of a loop in Excel 2007? Don Excel Discussion (Misc queries) 0 April 30th 09 06:49 PM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM


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