Good Morning - I have some problem with this function, it's running into an infinite loop. All I want is to insert rows based an a number. For example if:
frmSAGE.txtConsolePorts.Text = 5. Insert 5 rows
rngRefName = "EndNumCSLconsolports"
Public Sub layout_input_sheet()
Dim rngRefName As Range, intNumOfRows As Integer
Sheets("INPUT_SHEET").Select
Sheets("INPUT_SHEET").Range("C22:C1000").Select
For Each rngRefName In Selection.Cells
set rngRefName = selection
select case "EndNumCSLconsolports"
rngRefName = "EndNumCSLconsolports"
intNumOfRows = frmSAGE.txtConsolePorts.Text
Call insert_rows(rngRefName, intNumOfRows)
case Else
End select
Next
End Sub
Public Function insert_rows(ByVal rngRefNameVar As String, intRows As Integer)
Dim endOfSpecifiedTable As Range, startInsert As Integer
Dim intNumOfRowsToInsert As Integer
'find the specified reference name
Set endOfSpecifiedTable = Sheets("INPUT_SHEET").UsedRange.Find(rngRefNameVar, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
'select the Reference definning the end of the table
endOfSpecifiedTable.Select
'number of rows to be inserted
intNumOfRowsToInsert = intRows
startInsert = 1
'insert rows based on the number of PP15kSites
For startInsert = 1 To intNumOfRowsToInsert
If intNumOfRowsToInsert > 1 Then
Selection.EntireRow.Insert
Else
End If
Next
End Function
frmSAGE.txtConsolePorts.Text = 5. Insert 5 rows
rngRefName = "EndNumCSLconsolports"
Public Sub layout_input_sheet()
Dim rngRefName As Range, intNumOfRows As Integer
Sheets("INPUT_SHEET").Select
Sheets("INPUT_SHEET").Range("C22:C1000").Select
For Each rngRefName In Selection.Cells
set rngRefName = selection
select case "EndNumCSLconsolports"
rngRefName = "EndNumCSLconsolports"
intNumOfRows = frmSAGE.txtConsolePorts.Text
Call insert_rows(rngRefName, intNumOfRows)
case Else
End select
Next
End Sub
Public Function insert_rows(ByVal rngRefNameVar As String, intRows As Integer)
Dim endOfSpecifiedTable As Range, startInsert As Integer
Dim intNumOfRowsToInsert As Integer
'find the specified reference name
Set endOfSpecifiedTable = Sheets("INPUT_SHEET").UsedRange.Find(rngRefNameVar, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
'select the Reference definning the end of the table
endOfSpecifiedTable.Select
'number of rows to be inserted
intNumOfRowsToInsert = intRows
startInsert = 1
'insert rows based on the number of PP15kSites
For startInsert = 1 To intNumOfRowsToInsert
If intNumOfRowsToInsert > 1 Then
Selection.EntireRow.Insert
Else
End If
Next
End Function