Tag Archives: oop

ForEach loop object required error

Questions: Summary: I have a list of policy numbers I’m looping through in Column A using the for each loop Problem: Everything works except if there is an empty cell in Column A, my code deletes the entire row (as it should), but then when I try to set the policy variable I get a… Read More »

Counting non blank cell results without looping in Excel VBA — e.g., with Specialcells

Questions: Here is the code I’m trying to count with in VBA, hoping to return a count return variable of “3” from ‘FormulaResultCount’. Why can’t I count what is visibly returned by the formulas within each cell; from the grey box (see photo below)? Sub countNonBlanks() Worksheets(“Sheet1”).Select Range(“C:C”).Select FormulaResultCount = Selection.SpecialCells(xlCellTypeFormulas).Count ‘SpecialCells options from MSFT… Read More »

How to reverse a For loop

Questions: I have a problem with my macro. It deletes row that fullfil certain criteria. But when few consecutive rows fullfil those criteria an error occurs. When the row is deleted the other rows are shifted up so if i.e. row(2:2) and row(3:3) fullfil the criteria then the row(2:2) is deleted and row(3:3) is shifted… Read More »

Loop through a decimal sequence

Questions: I am writing a loop in VBA for excel, and I would like to loop through a sequence of decimal numbers, rather than integers. For example: For i = 1 To 10 ‘Do something Next i But rather than incrementibg by 1, I would like to increment by 0.5 (or perhaps 5, or really… Read More »

VBA looping through all series within all charts

Questions: I’m having an issue with the looping through of several charts in my VBA code. I’m 99.7% sure that this is a really easy and quick fix but my brain isn’t working today. I want the code to loop through every chart on the ActiveSheet, and for every data series that the chart contains… Read More »

VBA if else loop in excel returning #VALUE

Questions: Hi All in new to using VBA in excel and was trying to create a function that would look at a number and return it as a six digit number. The function I wrote to try and accomplish this is below but when I use the command =Res(A1) in a cell I just get… Read More »

Loop through all numbers in a range except a few

Questions: I need to loop through i = 1 to 99 but I want to skip a few specific i values. the numbers I want to skip are 41,83,87,91,92,93,98 I realize I could nest all my actions inside an i <> 41, or i <> 83 etc. Isn’t there an easier way? Maybe assign a… Read More »