Controlling Row Inserts and Deletes Via Code
Hi Ozzer,
Try:
'=============
Public Sub Tester()
Dim rng As Range, rng2 As Range
Set rng = ActiveCell
Set rng2 = Sheets("Sheet2").Range(rng.Address)
rng.EntireRow.Insert
rng2.EntireRow.Insert
rng2(0, 1).FormulaR1C1 = "=Sheet1!RC"
rng2(0, 2).FormulaR1C1 = "=Sheet1!RC-Sheet2!RC[1]-Sheet2!RC[2]"
End Sub
'<<=============
---
Regards,
Norman
"ozzer" wrote in message
oups.com...
This is the code the macro was generating
It seems to insert a new row on sheet 1 however on sheet 2 it does not
insert a row. It overwrites the row
Sheets(Array("Sheet1", "Sheet2")).Select
Selection.EntireRow.Insert
Sheets("Sheet2").Select
ActiveCell.FormulaR1C1 = "=Sheet1!RC"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=Sheet1!RC"
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=Sheet1!RC-Sheet2!RC[1]-Sheet2!RC[2]"
ActiveCell.Offset(1, 0).Range("A1").Select
Sheets("Sheet1").Select
ActiveCell.Select
Hopefully someone can help with this?
|