ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert new row after a name range (https://www.excelbanter.com/excel-programming/409871-insert-new-row-after-name-range.html)

Catherine[_6_]

Insert new row after a name range
 
Hi,

I am new on this site and I don't know really much about VBA, can you help
me?

I want to copy the validation of he cells A5:B5 and the formulas of cells
E5:F5 into a new row inserted after the range name "Training".

Thanks


Mike Fogleman[_2_]

Insert new row after a name range
 
Put this code in a module and run with the sheet active.

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy Range("A" & LRow)
Range("E5:F5").Copy Range("E" & LRow)
End Sub

Mike F
"Catherine" wrote in message
...
Hi,

I am new on this site and I don't know really much about VBA, can you help
me?

I want to copy the validation of he cells A5:B5 and the formulas of cells
E5:F5 into a new row inserted after the range name "Training".

Thanks




Catherine

Insert new row after a name range
 
Thanks Mike, your code is working but it's copying the contents also.
Can we just copy the validation and the formulas?

"Mike Fogleman" wrote:

Put this code in a module and run with the sheet active.

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy Range("A" & LRow)
Range("E5:F5").Copy Range("E" & LRow)
End Sub

Mike F
"Catherine" wrote in message
...
Hi,

I am new on this site and I don't know really much about VBA, can you help
me?

I want to copy the validation of he cells A5:B5 and the formulas of cells
E5:F5 into a new row inserted after the range name "Training".

Thanks





Mike Fogleman[_2_]

Insert new row after a name range
 
Try this:

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy
Range("A" & LRow).PasteSpecial Paste:=xlFormulas
Range("E5:F5").Copy
Range("E" & LRow).PasteSpecial Paste:=xlFormats
Application.CutCopyMode = False
End Sub

Mike F
"catherine" wrote in message
...
Thanks Mike, your code is working but it's copying the contents also.
Can we just copy the validation and the formulas?

"Mike Fogleman" wrote:

Put this code in a module and run with the sheet active.

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy Range("A" & LRow)
Range("E5:F5").Copy Range("E" & LRow)
End Sub

Mike F
"Catherine" wrote in message
...
Hi,

I am new on this site and I don't know really much about VBA, can you
help
me?

I want to copy the validation of he cells A5:B5 and the formulas of
cells
E5:F5 into a new row inserted after the range name "Training".

Thanks







Mike Fogleman[_2_]

Insert new row after a name range
 
OOPS, I got them reversed,

Try this:

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy
Range("A" & LRow).PasteSpecial Paste:=xlFormats
Range("E5:F5").Copy
Range("E" & LRow).PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
End Sub

Mike F

"Mike Fogleman" wrote in message
. ..
Try this:

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy
Range("A" & LRow).PasteSpecial Paste:=xlFormulas
Range("E5:F5").Copy
Range("E" & LRow).PasteSpecial Paste:=xlFormats
Application.CutCopyMode = False
End Sub

Mike F
"catherine" wrote in message
...
Thanks Mike, your code is working but it's copying the contents also.
Can we just copy the validation and the formulas?

"Mike Fogleman" wrote:

Put this code in a module and run with the sheet active.

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy Range("A" & LRow)
Range("E5:F5").Copy Range("E" & LRow)
End Sub

Mike F
"Catherine" wrote in message
...
Hi,

I am new on this site and I don't know really much about VBA, can you
help
me?

I want to copy the validation of he cells A5:B5 and the formulas of
cells
E5:F5 into a new row inserted after the range name "Training".

Thanks








Catherine

Insert new row after a name range
 
Hi Mike,

Your code is working perfectly, thank you for your help

Catherine

"Mike Fogleman" wrote:

OOPS, I got them reversed,

Try this:

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy
Range("A" & LRow).PasteSpecial Paste:=xlFormats
Range("E5:F5").Copy
Range("E" & LRow).PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
End Sub

Mike F

"Mike Fogleman" wrote in message
. ..
Try this:

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy
Range("A" & LRow).PasteSpecial Paste:=xlFormulas
Range("E5:F5").Copy
Range("E" & LRow).PasteSpecial Paste:=xlFormats
Application.CutCopyMode = False
End Sub

Mike F
"catherine" wrote in message
...
Thanks Mike, your code is working but it's copying the contents also.
Can we just copy the validation and the formulas?

"Mike Fogleman" wrote:

Put this code in a module and run with the sheet active.

Sub test()
Dim FRow As Integer, LRow As Integer
FRow = Range("Training").Row
LRow = Range("Training").Rows.Count + FRow
Rows(LRow).EntireRow.Insert
Range("A5:B5").Copy Range("A" & LRow)
Range("E5:F5").Copy Range("E" & LRow)
End Sub

Mike F
"Catherine" wrote in message
...
Hi,

I am new on this site and I don't know really much about VBA, can you
help
me?

I want to copy the validation of he cells A5:B5 and the formulas of
cells
E5:F5 into a new row inserted after the range name "Training".

Thanks










All times are GMT +1. The time now is 06:09 PM.

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