'Get current state of various Excel settings; put this at the beginning of your code screenUpdateState = Application.ScreenUpdating statusBarState = Application.DisplayStatusBar calcState = Application.Calculation eventsState = Application.EnableEvents displayPageBreakState = ActiveSheet.DisplayPageBreaks 'note this is a sheet-level setting 'turn off some Excel functionality so your code runs faster Application.ScreenUpdating = False Application.DisplayStatusBar = False Application.Calculation = xlCalculationManual Application.EnableEvents = False ActiveSheet.DisplayPageBreaks = False 'note this is a sheet-level setting '>>your code goes here<< 'after your code runs, restore state; put this at the end of your code Application.ScreenUpdating = screenUpdateState Application.DisplayStatusBar = statusBarState Application.Calculation = calcState Application.EnableEvents = eventsState ActiveSheet.DisplayPageBreaks = displayPageBreaksState 'note this is a sheet-level setting
Dim DataRange as Range Dim Irow as Long Dim Icol as Integer Dim MyVar as Double Set DataRange=Range("A1:C10000") For Irow=1 to 10000 For icol=1 to 3 MyVar=DataRange(Irow,Icol) 'Read values from the Excel grid 30K times If MyVar > 0 then MyVar=MyVar*Myvar ' Change the value DataRange(Irow,Icol)=MyVar 'Write values back into the Excel grid 30K times End If Next Icol Next Irow
Dim DataRange As Variant Dim Irow As Long Dim Icol As Integer Dim MyVar As Double DataRange = Range("A1:C10000").Value ' read all the values at once from the Excel grid, put into an array For Irow = 1 To 10000 For Icol = 1 To 3 MyVar = DataRange(Irow, Icol) If MyVar > 0 Then MyVar=MyVar*Myvar ' Change the values in the array DataRange(Irow, Icol) = MyVar End If Next Icol Next Irow Range("A1:C10000").Value = DataRange ' writes all the results back to the range at once
For i = 0 To ActiveSheet.Shapes.Count ActiveSheet.Shapes(i).Select Selection.Text = "Hello" Next i
For i = 0 To ActiveSheet.Shapes.Count ActiveSheet.Shapes(i).TextEffect.Text = "Hello" Next i
No comments:
Post a Comment