Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Toggle common tasks

Please forgive me, because I really don't know what I'm doing
yet much with VBA, but . . .

I'm already tired of typing at the top of each VBA module

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

and then turning it back on at the bottom. So I thought
of something like this:


=========================================
Public Sub toggleEvents(evTog As Boolean)
On Error Resume Next

evTog = Abs(evTog - 1)

With Application
.ScreenUpdating = evTog
.EnableEvents = evTog
End With

Debug.Print evTog & " Kilroy was here"

'On Error GoTo 0
End Sub
=========================================


Well, gee, but it says True all the time. What am I doing wrong?
Also, I tried Googling for similar things but so far have come up
empty. Does everybody really just turn that stuff off and back
on with lines of code in every module?

=dman=
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Toggle common tasks

On Aug 8, 5:26 pm, Dallman Ross <dman@localhost. wrote:
Please forgive me, because I really don't know what I'm doing
yet much with VBA, but . . .

I'm already tired of typing at the top of each VBA module

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

and then turning it back on at the bottom. So I thought
of something like this:

=========================================
Public Sub toggleEvents(evTog As Boolean)
On Error Resume Next

evTog = Abs(evTog - 1)

With Application
.ScreenUpdating = evTog
.EnableEvents = evTog
End With

Debug.Print evTog & " Kilroy was here"

'On Error GoTo 0
End Sub
=========================================

Well, gee, but it says True all the time. What am I doing wrong?
Also, I tried Googling for similar things but so far have come up
empty. Does everybody really just turn that stuff off and back
on with lines of code in every module?

=dman=


Hi Dallman,

Yes, I type it every time.

You could try...

Public Sub ToggleEvents()
With Application
.ScreenUpdating = Not .ScreenUpdating
.EnableEvents = Not .EnableEvents
End With
End Sub


Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Toggle common tasks

On Aug 8, 5:26 pm, Dallman Ross <dman@localhost. wrote:
Please forgive me, because I really don't know what I'm doing
yet much with VBA, but . . .

I'm already tired of typing at the top of each VBA module

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

and then turning it back on at the bottom. So I thought
of something like this:

=========================================
Public Sub toggleEvents(evTog As Boolean)
On Error Resume Next

evTog = Abs(evTog - 1)

With Application
.ScreenUpdating = evTog
.EnableEvents = evTog
End With

Debug.Print evTog & " Kilroy was here"

'On Error GoTo 0
End Sub
=========================================

Well, gee, but it says True all the time. What am I doing wrong?
Also, I tried Googling for similar things but so far have come up
empty. Does everybody really just turn that stuff off and back
on with lines of code in every module?

=dman=


Or, if you want to stick with what you've done so far, try...

Public Sub toggleEvents(evTog As Boolean)
On Error Resume Next

evTog = Not evTog

With Application
.ScreenUpdating = evTog
.EnableEvents = evTog
End With

Debug.Print evTog & " Kilroy was here"

'On Error GoTo 0
End Sub

Ken Johnson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Toggle common tasks

I am sure that MZtools has the capability to dump in a predefined Sub or
Event template that has all your default commands (which you define) and so
forth:

http://www.mztools.com/index.aspx

--
Regards,
Tom Ogilvy


"Dallman Ross" wrote:

Please forgive me, because I really don't know what I'm doing
yet much with VBA, but . . .

I'm already tired of typing at the top of each VBA module

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

and then turning it back on at the bottom. So I thought
of something like this:


=========================================
Public Sub toggleEvents(evTog As Boolean)
On Error Resume Next

evTog = Abs(evTog - 1)

With Application
.ScreenUpdating = evTog
.EnableEvents = evTog
End With

Debug.Print evTog & " Kilroy was here"

'On Error GoTo 0
End Sub
=========================================


Well, gee, but it says True all the time. What am I doing wrong?
Also, I tried Googling for similar things but so far have come up
empty. Does everybody really just turn that stuff off and back
on with lines of code in every module?

=dman=

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Toggle common tasks

In . com, Ken
Johnson spake thusly:

[WRT ScreenUpdating/EnableEvents off/on]


Hi Dallman,
Yes, I type it every time.


:-)

You could try...

Public Sub ToggleEvents()
With Application
.ScreenUpdating = Not .ScreenUpdating
.EnableEvents = Not .EnableEvents
End With
End Sub


Ken, that looks simple enough. Much appreciated, also for your
other answer. I will play some more and see how it works out . . . .

=dman=
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
Combining two ranges based on common a common value ahmed[_3_] Excel Discussion (Misc queries) 5 April 18th 09 05:04 PM
Exporting tasks se7098 Excel Worksheet Functions 2 January 21st 09 03:37 PM
Common footer but not common margins please -(Page 1 of 2) etc RajenRajput1 Excel Discussion (Misc queries) 9 August 26th 08 06:56 PM
combining tasks SusanL[_3_] Excel Programming 0 June 16th 05 12:17 AM
Automating some tasks Justin C Excel Discussion (Misc queries) 0 April 27th 05 12:45 PM


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