' Defines LastCol as the last column with a header on the Run sheet Any help you can give would be GREATLY appreciated!!! ReplyĬan someone help me with the following script? There is something wrong with the last call function of this.ĭim Cell As Range, sRange As Range, Rng As Range I am trying to sum cells that are conditionally formatted red. Hex(indRefColor) & vbCrLf,, "Count & Sum by Conditional Format color" MsgBox "Count=" & cntRes & vbCrLf & "Sum= " & sumRes & vbCrLf & vbCrLf & _ SumRes = WorksheetFunction.Sum(Selection(indCurCell), sumRes) If indRefColor = Selection(indCurCell). Then IndRefColor = cellsColorSample.Cells(1, 1). If Not (cellsColorSample Is Nothing) Then "Select sample color:", "Select a cell with sample color", _, Type:=8)Īny ideas what I need to change? I'm sorry but I know little of VB Scripting so I'm just trying to follow directions here. Set cellsColorSample = Application.InputBox( _ I'm currently trying to use it and I have followed the steps as written but when I go to the run the macro I get a syntax error on this line: Two best ways to convert numbers to words in Excel.How to count and sum cells by color in Excel - VBA macro.Then select the wanted macro from the "Macro Name" list and click the "Run" button. When you want to run the VBA code that you added as described in the section above: press Alt+F8 to open the " Macro" dialog. Press Alt + Q to close the Editor window and switch back to your workbook.Choose " Excel macro-enabled workbook" from the " Save as type" drop-down list and click the Save button. Press Crl + S, then click the " No" button in the " The following features cannot be saved in macro-free workbook" warning dialog. Save your workbook as " Excel macro-enabled workbook".As a result, the performance is increased from 10% to 500% (aha, the macro works 5 times faster if it continuously manipulates the cells' contents). These lines, as their names suggest, turn off screen refresh and recalculating the workbook's formulas before running the macro.Īfter the code is executed, everything is turned back on. To the very of the code, before End Sub:Īpplication.Calculation = xlCalculationAutomatic.To the very beginning of the code, after all code lines that start with Dim (if there are no " Dim" lines, then add them right after the Sub line):.Then add the following lines to get your macro to work faster (see the screenshots above): If the code of your VBA macro does not contain the following lines in the beginning:Īpplication.Calculation = xlCalculationManual
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |