Faster Macro??

zilch4ry

Board Regular
Joined
Feb 27, 2011
Messages
76
Hello everyone,

This is probably a stupid question, but is there a faster way of using this macro? i mean it takes about 2 seconds before it has complete but the worst bit is having to watch it skip through all of the pages and ending on the wrong page i started on. if anybody could change this code it will be hugely appreciated!

Code:
Sub deletealldata()
'
' deletealldata Macro
'

'
    Range("H13").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H23").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H33").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H44").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H55").Select
    ActiveCell.FormulaR1C1 = "0"
    Sheets("Step3").Select
    Range("H12").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H21").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H29").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H38").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H48").Select
    ActiveCell.FormulaR1C1 = "0"
    Sheets("Step2").Select
    Range("H12").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H21").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H31").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H42").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H53").Select
    ActiveCell.FormulaR1C1 = "0"
    Sheets("Step1").Select
    Range("H12").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H22").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H32").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H43").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("H57").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("G13").Select
End Sub

Thanks ;)
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try this:
The Sheets("Step4").Activate is an assumption; please update accordingly

Code:
    [COLOR=royalblue]'Sheets("Step4").Activate ' ??
[/COLOR]    Range("H13").FormulaR1C1 = "0"
    Range("H23").FormulaR1C1 = "0"
    Range("H33").FormulaR1C1 = "0"
    Range("H44").FormulaR1C1 = "0"
    Range("H55").FormulaR1C1 = "0"
 
    Sheets("Step3").Activate
    Range("H12").FormulaR1C1 = "0"
    Range("H21").FormulaR1C1 = "0"
    Range("H29").FormulaR1C1 = "0"
    Range("H38").FormulaR1C1 = "0"
    Range("H48").FormulaR1C1 = "0"
 
    Sheets("Step2").Activate
    Range("H12").FormulaR1C1 = "0"
    Range("H21").FormulaR1C1 = "0"
    Range("H31").FormulaR1C1 = "0"
    Range("H42").FormulaR1C1 = "0"
    Range("H53").FormulaR1C1 = "0"
 
    Sheets("Step1").Activate
    Range("H12").FormulaR1C1 = "0"
    Range("H22").FormulaR1C1 = "0"
    Range("H32").FormulaR1C1 = "0"
    Range("H43").FormulaR1C1 = "0"
    Range("H57").FormulaR1C1 = "0"
    Range("G13").FormulaR1C1 = "0"
 
Upvote 0
I'll half answer your question...If you're happy with the code as is, just add Application.ScreenUpdating=False before the code and Application.ScreenUpdating=True after the code and that will stop the flashy screen thingy and speed it up a bit. And of course if you want it ending up at the first page you started, you just need to another another Sheet("whatever").Select at the end as well (but before the Application.ScreenUpdating line).
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top