Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have been writing a macro that does the exact same thing, it adds row and calculates the previous row divided by the bottom of th previous row, which is a total. This gives the percentage of th total. This all worked fine. Then I had to add two rows and take the percentage of that. I made new row that was the addition of the two previous rows. That work fine, but now the maco that was working on all the other rows, won work on the new row. It gives me an overflow error and I cant figur out why... any suggestions? Here is a snippet of my macro. The green text is the part that works. The blue text is the addition part, which also works but could b leading to the overflow. The yellow part is the area that does no work, and the red is where the overflow is specifically occuring: Columns("ac:ac").Select Selection.Insert Shift:=xlToRight Dim varTotal, var7, var8 var7 = Range("ac2") var8 = Range("ab1").Select Selection.End(xlDown).Select ReportLastRow = ActiveCell.Row varTotal = var7 / var8 Range("ac2").Select ActiveCell.FormulaR1C1 = _ varTotal Set r = Range("ab1").End(xlDown) s = r.AddressLocal(True, True, xlR1C1) For i = 1 To r.Row Range("ac2").Select ActiveCell.FormulaR1C1 = "=RC[-1] / " & s Next i If IsEmpty(ActiveCell) Then Exit Sub Range(ActiveCell, ActiveCell.Offset(0, -1).End(xlDown).Offset(0 1)).FillDown Columns("af:af").Select Selection.Insert Shift:=xlToRight Range("Af1").Select ActiveCell.FormulaR1C1 = "FIX & COM" Range("af2").Select ActiveCell.FormulaR1C1 = "=RC[-1]+RC[-2]" If IsEmpty(ActiveCell) Then Exit Sub Range(ActiveCell, ActiveCell.Offset(0, -1).End(xlDown).Offset(0 1)).FillDown Columns("ag:ag").Select Selection.Insert Shift:=xlToRight Dim blahTotal, var9, var10 var7 = Range("ag2") var8 = Range("af1").Select Selection.End(xlDown).Select ReportLastRow = ActiveCell.Row blahTotal = var9 / var10 Range("ag2").Select ActiveCell.FormulaR1C1 = _ blahTotal Set r = Range("af1").End(xlDown) s = r.AddressLocal(True, True, xlR1C1) For i = 1 To r.Row Range("ag2").Select ActiveCell.FormulaR1C1 = "=RC[-1] / " & s Next i If IsEmpty(ActiveCell) Then Exit Sub Range(ActiveCell, ActiveCell.Offset(0, -1).End(xlDown).Offset(0 1)).FillDow -- mkerste ----------------------------------------------------------------------- mkerstei's Profile: http://www.excelforum.com/member.php...fo&userid=2568 View this thread: http://www.excelforum.com/showthread.php?threadid=56078 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Overflow error.. why? | Excel Discussion (Misc queries) | |||
Overflow error | Excel Programming | |||
Overflow Error | Excel Programming | |||
Overflow error | Excel Programming | |||
overflow error | Excel Programming |