Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to create a macro that a user can insert a row or rows based on
input boxes at any desired row. The code I have put together is below (there is more to it than this but this is the base). The problem is with the line, Rows("InsertRow:EndRow").Select It errors out. Any suggestions would be appreciated. I am using Excel 97. Dim InsertRow As Integer Dim NumberOfRows As Integer Dim EndRow As Integer InsertRow = InputBox("Enter the Row Number where you want to Insert the row.") NumberOfRows = InputBox("Enter how many Rows you want to Insert.") EndRow = InsertRow + NumberOfRows Rows("InsertRow:endrow").Select Selection.Insert Shift:=xlDown appeng |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the following:
Dim InsertRow As Integer Dim NumberOfRows As Integer Dim EndRow As Integer InsertRow = InputBox("Enter the Row Number where you want to Insert the row.") NumberOfRows = InputBox("Enter how many Rows you want to Insert.") EndRow = InsertRow + NumberOfRows Rows(InsertRow).Resize(NumberOfRows).Insert -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "appeng" wrote in message ... I am trying to create a macro that a user can insert a row or rows based on input boxes at any desired row. The code I have put together is below (there is more to it than this but this is the base). The problem is with the line, Rows("InsertRow:EndRow").Select It errors out. Any suggestions would be appreciated. I am using Excel 97. Dim InsertRow As Integer Dim NumberOfRows As Integer Dim EndRow As Integer InsertRow = InputBox("Enter the Row Number where you want to Insert the row.") NumberOfRows = InputBox("Enter how many Rows you want to Insert.") EndRow = InsertRow + NumberOfRows Rows("InsertRow:endrow").Select Selection.Insert Shift:=xlDown appeng |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
IT WOEKS GREAT!
Many Thanks Can I ask one other question? If I now want to copy the formatting from the row just below the inserted rows to the newly inserted rows, do you have any suggestions? Once again Thank You "Chip Pearson" wrote: Try the following: Dim InsertRow As Integer Dim NumberOfRows As Integer Dim EndRow As Integer InsertRow = InputBox("Enter the Row Number where you want to Insert the row.") NumberOfRows = InputBox("Enter how many Rows you want to Insert.") EndRow = InsertRow + NumberOfRows Rows(InsertRow).Resize(NumberOfRows).Insert -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "appeng" wrote in message ... I am trying to create a macro that a user can insert a row or rows based on input boxes at any desired row. The code I have put together is below (there is more to it than this but this is the base). The problem is with the line, Rows("InsertRow:EndRow").Select It errors out. Any suggestions would be appreciated. I am using Excel 97. Dim InsertRow As Integer Dim NumberOfRows As Integer Dim EndRow As Integer InsertRow = InputBox("Enter the Row Number where you want to Insert the row.") NumberOfRows = InputBox("Enter how many Rows you want to Insert.") EndRow = InsertRow + NumberOfRows Rows("InsertRow:endrow").Select Selection.Insert Shift:=xlDown appeng |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to increase the shading when highlighting mult. rows w/ mouse | Excel Discussion (Misc queries) | |||
Comparing data in mult rows then summing unique values | Excel Discussion (Misc queries) | |||
Vlookup to insert num in mult. columns | Excel Discussion (Misc queries) | |||
I want to be able to insert 1 Excel Wkbk (w mult tabs) into anothe | Excel Worksheet Functions | |||
Need help with array formula to count rows w/ mult.criteria | Excel Programming |