ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA and insert question (https://www.excelbanter.com/excel-programming/421884-vba-insert-question.html)

teepee[_3_]

VBA and insert question
 
Hello

I hve some code that inserts 4 lines into a spreadsheet one at a time

Is there a line of code that would permit me to put in 4 lines in one go?

Many thanks

With Sheets("sheet1").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Sheets("sheet1").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Sheets("sheet1").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Sheets("sheet1P").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With



Per Jessen[_2_]

VBA and insert question
 
Hi

Expand the range to be 4 rows:

With Sheets("Sheet1").range("BL1:BX4")
....


Regards,
Per

On 2 Jan., 01:16, "teepee" wrote:
Hello

I hve some code that inserts 4 lines into a spreadsheet one at a time

Is there a line of code that would permit me to put in 4 lines in one go?

Many thanks

With Sheets("sheet1").Range("BL1:BX1")
* * .Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
* * End With
* * With Sheets("sheet1").Range("BL1:BX1")
* * .Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
* * End With
* * With Sheets("sheet1").Range("BL1:BX1")
* * .Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
* * End With
* * With Sheets("sheet1P").Range("BL1:BX1")
* * .Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
* * End With



teepee[_3_]

VBA and insert question
 

"Per Jessen" wrote .
Hi

Expand the range to be 4 rows:

D'oh thanks



Don Guillett

VBA and insert question
 
Sub insert4rows()
Sheets("sheet1").Range("BL1").Resize(4).EntireRow. Insert
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teepee" wrote in message
...
Hello

I hve some code that inserts 4 lines into a spreadsheet one at a time

Is there a line of code that would permit me to put in 4 lines in one go?

Many thanks

With Sheets("sheet1").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Sheets("sheet1").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Sheets("sheet1").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With Sheets("sheet1P").Range("BL1:BX1")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End With




All times are GMT +1. The time now is 05:51 AM.

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