ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to Insert and copy entire row (https://www.excelbanter.com/excel-discussion-misc-queries/147971-macro-insert-copy-entire-row.html)

CCrew2000

Macro to Insert and copy entire row
 
I'm trying to create a macro that goes to the last row of data, goes to the
next row and then inserts a row. I then need it to copy & paste from the row
above it (formulas & formats only). Here is what I have so far, but its not
working.

range("A7").Select
Selection.End(xlDown).Select , Offset(1, 0)
Selection.EntireRow.Insert

range("NewPartDescr").Offset(-2, 0).EntireRow.Copy
range("NewPartDescr").Offset(-1, 1).EntireRow.Select

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False


Don Guillett

Macro to Insert and copy entire row
 
Without selections.

Sub copylastrowdown()
lr = Cells(Rows.Count, "a").End(xlUp).row
Rows(lr).Copy
Rows(lr + 1).PasteSpecial Paste:=xlPasteFormats
Rows(lr + 1).PasteSpecial Paste:=xlPasteFormulas
'cells(lr + 1,"a").select 'uncomment to select
End Sub

--
Don Guillett
SalesAid Software

"CCrew2000" wrote in message
...
I'm trying to create a macro that goes to the last row of data, goes to
the
next row and then inserts a row. I then need it to copy & paste from the
row
above it (formulas & formats only). Here is what I have so far, but its
not
working.

range("A7").Select
Selection.End(xlDown).Select , Offset(1, 0)
Selection.EntireRow.Insert

range("NewPartDescr").Offset(-2, 0).EntireRow.Copy
range("NewPartDescr").Offset(-1, 1).EntireRow.Select

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False



CCrew2000

Macro to Insert and copy entire row
 
Two issues:
1) a row wasn't inserted
2) values were copied as well

"Don Guillett" wrote:

Without selections.

Sub copylastrowdown()
lr = Cells(Rows.Count, "a").End(xlUp).row
Rows(lr).Copy
Rows(lr + 1).PasteSpecial Paste:=xlPasteFormats
Rows(lr + 1).PasteSpecial Paste:=xlPasteFormulas
'cells(lr + 1,"a").select 'uncomment to select
End Sub

--
Don Guillett
SalesAid Software

"CCrew2000" wrote in message
...
I'm trying to create a macro that goes to the last row of data, goes to
the
next row and then inserts a row. I then need it to copy & paste from the
row
above it (formulas & formats only). Here is what I have so far, but its
not
working.

range("A7").Select
Selection.End(xlDown).Select , Offset(1, 0)
Selection.EntireRow.Insert

range("NewPartDescr").Offset(-2, 0).EntireRow.Copy
range("NewPartDescr").Offset(-1, 1).EntireRow.Select

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False




Don Guillett

Macro to Insert and copy entire row
 

Give an illustration or send me a workbook.
--
Don Guillett
SalesAid Software

"CCrew2000" wrote in message
...
Two issues:
1) a row wasn't inserted
2) values were copied as well

"Don Guillett" wrote:

Without selections.

Sub copylastrowdown()
lr = Cells(Rows.Count, "a").End(xlUp).row
Rows(lr).Copy
Rows(lr + 1).PasteSpecial Paste:=xlPasteFormats
Rows(lr + 1).PasteSpecial Paste:=xlPasteFormulas
'cells(lr + 1,"a").select 'uncomment to select
End Sub

--
Don Guillett
SalesAid Software

"CCrew2000" wrote in message
...
I'm trying to create a macro that goes to the last row of data, goes to
the
next row and then inserts a row. I then need it to copy & paste from
the
row
above it (formulas & formats only). Here is what I have so far, but
its
not
working.

range("A7").Select
Selection.End(xlDown).Select , Offset(1, 0)
Selection.EntireRow.Insert

range("NewPartDescr").Offset(-2, 0).EntireRow.Copy
range("NewPartDescr").Offset(-1, 1).EntireRow.Select

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False






All times are GMT +1. The time now is 03:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com