Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I can barely tell that the macro is even running! You are the Man.
Thanks very much for your help! "Ryan H" wrote: There are a few things you can do to speed your macro up. 1.) Declare your variables. You have a variable a that should be declared as Dim a As Long. 2.) You can use the With Statement 3.) When looping through objects, in your case cells in a range, I would recommend using the For Each...Next Loop instead of the For...Next Loop Try this code. Hope this helps! If so, let me know, click "YES" below. Sub SlowMacro() Dim MyRange As Range Dim rng As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set MyRange = Range("A3:DS3") MyRange.EntireColumn.Hidden = False For Each rng In MyRange If rng.Value = "Hide Column" Then rng.EntireColumn.Hidden = True End If Next rng With Application .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With End Sub -- Cheers, Ryan "jm913" wrote: I have a fairly simple macro that is runnning slow for some reason. Here is the code Application.ScreenUpdating = False ActiveCell.Range("A1:DS1").Select Selection.EntireColumn.Hidden = False ActiveCell.Select Application.Calculation = xlCalculationManual For a = 3 To 200 If Range("D3").Offset(0, a).Value = "Hide Column" Then Range("D3").Offset(0, a).EntireColumn.Hidden = True Next a Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True Any ideas? -- Thanks for your help! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
slow macro | Excel Discussion (Misc queries) | |||
Slow macro | Excel Programming | |||
Slow Macro | Excel Programming | |||
slow macro | Excel Programming | |||
Slow macro | Excel Programming |