Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Code skipping when screenupdating is turned off

I have several modules that run in succession. However, when I have screen
updating turned off it jumps over one small module. When I'm testing the
code and have screen updating turned on, it works fine. I have also tried
putting a breakpoint in the code with screenupdating turned off but it still
just skips over it.

I'm confuzzled.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Code skipping when screenupdating is turned off

Here's the call to this procedure with a preceding for next loop:

:::::::Screenupdating is turned off at the begining of this procedure.
For AA = 2 To TotResCount
AAStr = AA
Range("BN" + AAStr + "").Select
ActiveCell.Value = "=Sum(M" + AAStr + ":BM" + AAStr + ")"
Range("L" + AAStr + "").Activate
If ActiveCell.Offset(0, -6).Value = "Alloc" Then
ActiveCell.Value = "=Sum(BN" + AAStr + ")"
ActiveCell.Offset(0, -1).Value = "=Sum(L" + AAStr + " - J" +
AAStr + ")"
End If
Next AA
Application.Run "AddResSheets"

++++++++++THIS IS THE CODE IT SKIPS:

Public Sub AddResSheets()
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
'Range("DataRange").Select
TtlRows = Selection.Rows.Count - 1

For a = 2 To TtlRows
Sheets("1-Consolidated").Activate
Range("A" + CStr(a) + "").Activate
ResName = ActiveCell.Value
If ResName < ActiveCell.Offset(-1, 0) And ResName < "Resource" Then
Range("A1:BN1").Select
Selection.Copy
Set NewSheet = Sheets.Add(Type:=xlWorksheet)
NewSheet.Name = ResName
x = 2
ActiveSheet.Paste
Range("A" + CStr(x) + "").Activate
ActiveCell.Value = "='1-Consolidated'!A" + CStr(a) + ""
Range("A" + CStr(x) + ": BN" + CStr(x) + "").Select
Selection.FillRight

ElseIf ResName < "" Then
x = x + 1
Sheets("" + ResName + "").Activate
Range("A" + CStr(x) + "").Activate
ActiveCell.Value = "='1-Consolidated'!A" + CStr(a) + ""
Range("A" + CStr(x) + ": BN" + CStr(x) + "").Select
Selection.FillRight
End If

Next a
Application.Run "FrmWksheet"
End Sub

+++++++++and this is the follow on code:

Public Sub FrmWksheet()
Wrksht = 2
For Each W In Worksheets
:::::::lots of code
Next
End sub
"RominallL" wrote:

I have several modules that run in succession. However, when I have screen
updating turned off it jumps over one small module. When I'm testing the
code and have screen updating turned on, it works fine. I have also tried
putting a breakpoint in the code with screenupdating turned off but it still
just skips over it.

I'm confuzzled.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Code skipping when screenupdating is turned off


Screenupdating does not affect code execution only what is cureently
visible. So that is not the cause of your problem.
What is the value of TtlRows? More than 2 ?
Put a msgbox or "Debug.Assert False" statement at the top of the problem
routine to ensure it is actual fired.

Note also that if you really are concatenating strings (as opposed to adding
numbers), if is better to use "&" instead of "+".
Also, there is seldom any good reason to .select/.Activate object before
using them in Excel. e.g.

Range("BN" & AAStr).Value = "=Sum(M" & AAStr & ":BM" & AAStr & ")"
With Range("L" & AAStr)
If .Offset(0, -6).Value = "Alloc" Then
.Value = "=Sum(BN" & AAStr & ")"
'etc
End If
End With

NickHK

"RominallL" wrote in message
...
Here's the call to this procedure with a preceding for next loop:

:::::::Screenupdating is turned off at the begining of this procedure.
For AA = 2 To TotResCount
AAStr = AA
Range("BN" + AAStr + "").Select
ActiveCell.Value = "=Sum(M" + AAStr + ":BM" + AAStr + ")"
Range("L" + AAStr + "").Activate
If ActiveCell.Offset(0, -6).Value = "Alloc" Then
ActiveCell.Value = "=Sum(BN" + AAStr + ")"
ActiveCell.Offset(0, -1).Value = "=Sum(L" + AAStr + " - J" +
AAStr + ")"
End If
Next AA
Application.Run "AddResSheets"

++++++++++THIS IS THE CODE IT SKIPS:

Public Sub AddResSheets()
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
'Range("DataRange").Select
TtlRows = Selection.Rows.Count - 1

For a = 2 To TtlRows
Sheets("1-Consolidated").Activate
Range("A" + CStr(a) + "").Activate
ResName = ActiveCell.Value
If ResName < ActiveCell.Offset(-1, 0) And ResName < "Resource"

Then
Range("A1:BN1").Select
Selection.Copy
Set NewSheet = Sheets.Add(Type:=xlWorksheet)
NewSheet.Name = ResName
x = 2
ActiveSheet.Paste
Range("A" + CStr(x) + "").Activate
ActiveCell.Value = "='1-Consolidated'!A" + CStr(a) + ""
Range("A" + CStr(x) + ": BN" + CStr(x) + "").Select
Selection.FillRight

ElseIf ResName < "" Then
x = x + 1
Sheets("" + ResName + "").Activate
Range("A" + CStr(x) + "").Activate
ActiveCell.Value = "='1-Consolidated'!A" + CStr(a) + ""
Range("A" + CStr(x) + ": BN" + CStr(x) + "").Select
Selection.FillRight
End If

Next a
Application.Run "FrmWksheet"
End Sub

+++++++++and this is the follow on code:

Public Sub FrmWksheet()
Wrksht = 2
For Each W In Worksheets
:::::::lots of code
Next
End sub
"RominallL" wrote:

I have several modules that run in succession. However, when I have

screen
updating turned off it jumps over one small module. When I'm testing

the
code and have screen updating turned on, it works fine. I have also

tried
putting a breakpoint in the code with screenupdating turned off but it

still
just skips over it.

I'm confuzzled.



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
reference row on another sheet skipping zeros but not skipping li. Brennan Downes Excel Discussion (Misc queries) 2 April 2nd 23 01:28 PM
AutoSum turned off? Leslee Excel Discussion (Misc queries) 2 June 2nd 08 01:27 PM
VBA code error with Protection turned on - help please Fred Excel Discussion (Misc queries) 1 March 17th 06 04:06 PM
Worksheet has turned TeeJay Excel Worksheet Functions 0 January 12th 06 08:44 AM
Skipping sections of code ExcelMonkey[_190_] Excel Programming 1 March 16th 05 12:57 PM


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