Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Code running slowly

Not sure why it runs slow. I thought the Application.ScreenUpdating =
False would do the trick.

Sub Holidays()

Application.ScreenUpdating = False

'New Years Day

With Sheets("January")

If Range("C4") = Range("R2") Then
Range("B27").Value = "New Years"
Range("B27").HorizontalAlignment = xlCenter
Range("B30").Value = "Day"
Range("B30").HorizontalAlignment = xlCenter
Range("A3").Select

ElseIf Range("B27") = "New Years" Then

Range("B27").Value = ""
Range("B27").HorizontalAlignment = xlLeft
Range("B27").IndentLevel = 1
Range("B30").Value = ""
Range("B30").HorizontalAlignment = xlLeft
Range("B30").IndentLevel = 1
Range("A3").Select

End If

If Range("E4") = Range("R2") Then
Range("D27").Value = "New Years"
Range("D27").HorizontalAlignment = xlCenter
Range("D30").Value = "Day"
Range("D30").HorizontalAlignment = xlCenter
Range("A3").Select

ElseIf Range("D27") = "New Years" Then

Range("D27").Value = ""
Range("D27").HorizontalAlignment = xlLeft
Range("D27").IndentLevel = 1
Range("D30").Value = ""
Range("D30").HorizontalAlignment = xlLeft
Range("D30").IndentLevel = 1
Range("A3").Select

End If

End With

Application.ScreenUpdating = True

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code running slowly


You're using a With/EndWith, but you're not using it. You should have
a "." in front of every Range statement (or other property associated
with the With object). See some updated code below, hopefully it runs
faster.


Code:
--------------------


Sub Holidays()
Application.ScreenUpdating = False

With Sheets("January")
If .Range("C4") = .Range("R2") Then
.Range("B27").Value = "New Years"
.Range("B27").HorizontalAlignment = xlCenter
.Range("B30").Value = "Day"
.Range("B30").HorizontalAlignment = xlCenter
ElseIf .Range("B27") = "New Years" Then
.Range("B27").Value = ""
.Range("B27").HorizontalAlignment = xlLeft
.Range("B27").IndentLevel = 1
.Range("B30").Value = ""
.Range("B30").HorizontalAlignment = xlLeft
.Range("B30").IndentLevel = 1
End If

If .Range("E4") = .Range("R2") Then
.Range("D27").Value = "New Years"
.Range("D27").HorizontalAlignment = xlCenter
.Range("D30").Value = "Day"
.Range("D30").HorizontalAlignment = xlCenter
ElseIf .Range("D27") = "New Years" Then
.Range("D27").Value = ""
.Range("D27").HorizontalAlignment = xlLeft
.Range("D27").IndentLevel = 1
.Range("D30").Value = ""
.Range("D30").HorizontalAlignment = xlLeft
.Range("D30").IndentLevel = 1
End If
.Range("A3").Select
End With
Application.ScreenUpdating = True
End Sub
--------------------


--
Paul

- Paul
------------------------------------------------------------------------
Paul's Profile: 1697
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=192721

http://www.thecodecage.com/forumz

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
Update "centerheader" code running slowly need help speeding up Breck Excel Programming 7 January 16th 09 06:18 AM
Macro with column delete running very slowly Code Numpty Excel Programming 11 October 2nd 08 03:15 PM
HELP...anybody got any ideas why this is running so slowly...... WhytheQ Excel Programming 6 September 3rd 07 10:42 AM
Can you help me figure out why my macro is running slowly? Phil Excel Programming 5 June 12th 07 11:54 PM
Paste code running extremely slowly... KR Excel Programming 1 August 3rd 05 03:26 PM


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