Good evening guys. I spent a lot of time working on an Excel Report that generates Installation Cards based on counting the rows in the schedule (which is an output from a Design Application) and creating individual sheets with the specific data from each row. However, today the guys asked that it should instead generate 2 different templates based on values in Column L or R, and in cases where both are completed, to generate both the cards. Currently, I was thinking a simple IF selection could do the trick, but I am not sure where exactly to start it from. The code for a single template looks as follows:
![]()
Sub GenerateTerminationCard() 'To check sheet existance Dim bExists As Boolean For i = 1 To Worksheets.Count If Worksheets(i).Name = "7" Then bExists = True End If Next i Sheets("Sheet1").Select If Worksheets("Sheet1").Range("b8").Value = "" Then ActiveSheet.Range("b7").Select Else ActiveSheet.Range("b7", ActiveSheet.Range("b7").End(xlDown)).Select End If Dim dNoOfTags As Double dNoOfTags = Selection.CountLarge ActiveSheet.Range("b" & dNoOfTags + 7, ActiveSheet.Range("b" & dNoOfTags + 7).End(xlDown)).EntireRow.Delete Dim nSelectedCells() As Integer ReDim nSelectedCells(dNoOfTags) As Integer For i = 1 To dNoOfTags nSelectedCells(i) = i Next If bExists = False Then 'Copying Termination Card sheets and rename Application.ScreenUpdating = False Sheets("Termination Card").Visible = True For i = 1 To dNoOfTags Sheets("Termination Card").Copy After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count) ActiveSheet.Name = (i + 6) Next 'Copying Cells from Sheet1 to Termination Cards For i = 7 To (dNoOfTags + 6) Worksheets("Sheet1").Range("B" & i).Copy Worksheets("" & i & "").Select Worksheets("" & i & "").Range("A8").Select Worksheets("" & i & "").PasteSpecial xlPasteValuesAndNumberFormats Worksheets("" & i & "").Range("A35").Select Worksheets("" & i & "").PasteSpecial xlPasteValuesAndNumberFormats Worksheets("" & i & "").Range("D54").Select Worksheets("" & i & "").PasteSpecial xlPasteValuesAndNumberFormats 'Worksheets("Sheet1").Range("X" & i).Copy 'Worksheets("" & i & "").Select 'Worksheets("" & i & "").Range("F8").Select 'Worksheets("" & i & "").PasteSpecial xlPasteValuesAndNumberFormats 'there are a lot more rows being copied but I removed for now Next Sheets("Termination Card").Visible = False Else Application.DisplayAlerts = False For i = 7 To dNoOfTags + 6 Sheets("" & i & "").Select ActiveWindow.SelectedSheets.Delete Next i Application.DisplayAlerts = True End If End Sub
I have already created the necessary Templates as sheets (named "Termination Card FROM" and "Termination Card TO" respectively).
Any help or advice would be greatly appreciated.
Bookmarks