S
StargateFanFromWork
I was so kindly given this code over a year ago by a kind poster in one of
these MS Excel ngs. I just applied it to a new spreadsheet today but
wondered why some coding I had in 2 cells wasn't being replicated. I then
remembered that it was only the formula in first cell that was repeated in
the subsequent new rows, as per the coding below since it somehow copies the
first cell.
In this new spreadsheet, all cells in A receive custom data so the first
cell doesn't need to have the formula copied. There are 2 distinct
formulas, however, in two other columns, columns D and F, that must be
replicated in any new rows. However, after studying and studying the code
below I can't figure out how to do this. Would appreciate help in this
regard.
Thanks so much in advance!! D
******************************************
Sub InsertROWS()
'
Dim i As Long
Dim j As Long
Dim k As Long
On Error GoTo dontdothat
Do
i = InputBox("How many rows do you want to insert?", "Insert Rows ",
1)
Loop Until i <> 0
Do
j = InputBox("At what Excel row number do you want to start the
insertion?", "Insert Rows", 10)
Loop Until j <> 0
k = j + i - 1
Range("" & j & ":" & k & "").Insert shift:=xlDown
j = j - 1
Range("A" & j & "").Select
Selection.AutoFill Destination:=Range("A" & j & ":A" & k & ""),
Type:=xlFillDefault
Range("A2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Exit Sub
dontdothat:
End Sub
******************************************
these MS Excel ngs. I just applied it to a new spreadsheet today but
wondered why some coding I had in 2 cells wasn't being replicated. I then
remembered that it was only the formula in first cell that was repeated in
the subsequent new rows, as per the coding below since it somehow copies the
first cell.
In this new spreadsheet, all cells in A receive custom data so the first
cell doesn't need to have the formula copied. There are 2 distinct
formulas, however, in two other columns, columns D and F, that must be
replicated in any new rows. However, after studying and studying the code
below I can't figure out how to do this. Would appreciate help in this
regard.
Thanks so much in advance!! D
******************************************
Sub InsertROWS()
'
Dim i As Long
Dim j As Long
Dim k As Long
On Error GoTo dontdothat
Do
i = InputBox("How many rows do you want to insert?", "Insert Rows ",
1)
Loop Until i <> 0
Do
j = InputBox("At what Excel row number do you want to start the
insertion?", "Insert Rows", 10)
Loop Until j <> 0
k = j + i - 1
Range("" & j & ":" & k & "").Insert shift:=xlDown
j = j - 1
Range("A" & j & "").Select
Selection.AutoFill Destination:=Range("A" & j & ":A" & k & ""),
Type:=xlFillDefault
Range("A2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Exit Sub
dontdothat:
End Sub
******************************************