Sub ASP_New_Application()
' ### NEW APPLICATION ###
Dim MyRow1 As String
Dim MyRow2 As String
Dim MyRow3 As String
Dim MyRow4 As String
Dim MyRow5 As String
Dim MyRow6 As String
Dim MyRow7 As String
Dim MyRow8 As String
MyRow1 = "5:22" 'Pre-Deployment Preparation
MyRow2 = "25:31" 'Deployment
MyRow3 = "34" 'Post Deployment
MyRow4 = "37:38" 'Test Deployment
MyRow5 = "42" 'Pre-Rollback Preparation
MyRow6 = "45:46" 'Rollback
MyRow7 = "49" 'Post Rollback
MyRow8 = "52:53" 'Test Rollback
Dim FindString As String
Dim Rng As Range
Dim AnswerToMessageBox As String
Dim MessageBoxContent As String
' Message Box Information
MessageBoxContent = "Are you sure you wish to continue with" & vbNewLine & vbNewLine & "with Automated Step Population?"
AnswerToMessageBox = MsgBox(MessageBoxContent, vbYesNo + vbQuestion, "New Application Step Population...")
If AnswerToMessageBox = vbYes Then
GoTo 0
Else
GoTo 1
End If
0:
Application.ScreenUpdating = False
With ActiveSheet.Unprotect
'Enter Search Value between the ""
FindString = "1"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow1).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
'Enter Search Value between the ""
FindString = "2"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow2).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
'Enter Search Value between the ""
FindString = "3"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow3).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
'Enter Search Value between the ""
FindString = "4"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow4).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
End With
'Enter Search Value between the ""
FindString = "5"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow5).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
'Enter Search Value between the ""
FindString = "6"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow6).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
'Enter Search Value between the ""
FindString = "7"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow7).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
'Enter Search Value between the ""
FindString = "8"
If Trim(FindString) <> "" Then
'Set The Search Range Between The ""
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)
'Moves To The Cell With The Value In
If Not Rng Is Nothing Then
Application.GoTo Rng, True
'Copys The Row Specified
Sheets("New Application Steps").Rows(MyRow8).Copy
'Inserts The Row Copied Above Beneath The Row Found With The Value In
Rng.Offset(1).EntireRow.Insert
Else
End If
End With
End If
Application.ScreenUpdating = True
Range("C7").Select
' Message Box Information
MessageBoxContent = "CAUTION: These Steps can only be removed MANUALLY if you click 'OK'." & vbNewLine & vbNewLine & "To remove these Steps click 'Cancel' or click 'OK' to accept them and continue."
AnswerToMessageBox = MsgBox(MessageBoxContent, vbOKCancel + vbExclamation, "Automated Step Population Completed...")
If AnswerToMessageBox = vbCancel Then
GoTo Remove
Else
GoTo 1
End If
Remove:
Application.ScreenUpdating = True
With ActiveSheet.Unprotect
Rows(MyRow8).Delete
With ActiveSheet.Unprotect
Rows(MyRow7).Delete
With ActiveSheet.Unprotect
Rows(MyRow6).Delete
With ActiveSheet.Unprotect
Rows(MyRow5).Delete
With ActiveSheet.Unprotect
Rows(MyRow4).Delete
With ActiveSheet.Unprotect
Rows(MyRow3).Delete
With ActiveSheet.Unprotect
Rows(MyRow2).Delete
With ActiveSheet.Unprotect
Rows(MyRow1).Delete
With ActiveSheet.Unprotect
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowInsertingRows:=True, AllowDeletingRows _
:=True
End With
End With
End With
End With
End With
End With
End With
End With
End With
' Message Box Information
MessageBoxContent = "The common Steps for a New Application deployment have been removed."
AnswerToMessageBox = MsgBox(MessageBoxContent, vbOKOnly + vbInformation, "Steps Removed Successfully...")
If AnswerToMessageBox = vbOKOnly Then
GoTo 1
Else
GoTo 1
End If
1:
Application.ScreenUpdating = True
End Sub