C
Carroll
Hello,
I picked up some VBA that inserts a row, then copies the values down
from the row above to the new row, then keeps only those values in the
new row that contain formulas:
Sheets("IDA MI WrkGrp Rpt").Select
Range("A13").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate ' this finds the first cell
in the colum with
' nothing in it.
ActiveCell.Offset(-1).Activate - this moves me up one, to the last
cell with an entry.
ActiveCell.Offset(1).EntireRow.Insert
ActiveCell.EntireRow.Copy ActiveCell.Offset(1).EntireRow
On Error Resume Next
ActiveCell.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
I modied it slightly to ignore errors coming from the ClearContents
when it finds no constants on that line.
Here is my problem. While it inserts the row, then keeps only cells
with formulas, not all of the formulas contain the values I expect.
For instance, where a cell copied down contains
=(SUM(B$14:B15)-SUM(D$1415)), the cell below it now has
=(SUM(B$14:B16)-SUM(D$1416)), which is correct. But for a cell that
contains =Receipt!B5, the cell below it has =Receipt!B7. Why did it
not contain =Receipt!B6? Why did it skip a number?
Very strange.
Thanks for reading.
Carroll Rinehart
I picked up some VBA that inserts a row, then copies the values down
from the row above to the new row, then keeps only those values in the
new row that contain formulas:
Sheets("IDA MI WrkGrp Rpt").Select
Range("A13").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate ' this finds the first cell
in the colum with
' nothing in it.
ActiveCell.Offset(-1).Activate - this moves me up one, to the last
cell with an entry.
ActiveCell.Offset(1).EntireRow.Insert
ActiveCell.EntireRow.Copy ActiveCell.Offset(1).EntireRow
On Error Resume Next
ActiveCell.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
I modied it slightly to ignore errors coming from the ClearContents
when it finds no constants on that line.
Here is my problem. While it inserts the row, then keeps only cells
with formulas, not all of the formulas contain the values I expect.
For instance, where a cell copied down contains
=(SUM(B$14:B15)-SUM(D$1415)), the cell below it now has
=(SUM(B$14:B16)-SUM(D$1416)), which is correct. But for a cell that
contains =Receipt!B5, the cell below it has =Receipt!B7. Why did it
not contain =Receipt!B6? Why did it skip a number?
Very strange.
Thanks for reading.
Carroll Rinehart