How would you guys suggest handling this.
When this code was written all the aircraft we were using had 2 engines and now we have aircraft that are single engines as well but the code auto inputs 2 rows 1 for each engine position even though that particular aircraft only has 1 engine.
Unfortunately i inherited this excel document and my VBA skills are far less then the person before me.
the code has made life pretty simple and if I just have to keep deleting the 2nd row then I guess I can live with that but I imagine theres a easy solution, at least I hope.
I was thinking of adding a vlookup table on the LIST tab with Aircraft models and a number for how many engines those model aircraft have so when the code ran it would look to see how many rows to create?
I think im on the right track but I'm not sure how to do it.
Any help would be appreciated!
Private Sub populateEnginePosition(acAmuIn As String) Dim wsDailyInput As Worksheet: Set wsDailyInput = Sheets("Daily Input") Dim wsList As Worksheet: Set wsList = Sheets("List") Dim wsData As Worksheet: Set wsData = Sheets("data") Dim acAmuInput() As String Dim acType As String Dim amuName As String Dim listItems As String Dim acNumber As Integer Dim enginePosition As Integer Dim lastRow As Long Dim currTime As Date currTime = Now - TimeSerial(0, 13, 0) acNumber = acAmuIn enginePosition = 1 lastRow = wsDailyInput.Range("a1048576").End(xlUp).Row If lastRow < 6 Then lastRow = 6 Else lastRow = lastRow + 1 End If '' Get aircraft type On Error Resume Next amuName = WorksheetFunction.VLookup(acNumber, wsList.Range("I2:K52"), 2, False) acType = WorksheetFunction.VLookup(acNumber, wsList.Range("I2:K52"), 3, False) If Err.Number <> 0 Then MsgBox "Aircraft not listed in lookup-table" End If For enginePosition = 1 To 2 '' Populate Daily input worksheet With wsDailyInput .Range("a" & lastRow).Value = amuName .Range("b" & lastRow).Value = acType .Range("c" & lastRow).Value = acNumber .Range("d" & lastRow).Value = enginePosition .Range("e" & lastRow).Value = Cells(2, 5).Value ''Computer Clock is 13 mins fast .Range("f" & lastRow).Value = Format(Now() - TimeValue("00:13:00"), "hh:mm") With .Range("i" & lastRow).Validation .Delete .Add Type:=xlValidateList, Formula1:="=LabCodes" .IgnoreBlank = True .InCellDropdown = True End With .Range("y" & lastRow).Formula = "=IF(E" & lastRow & "=0,0,F" & lastRow & "-E" & lastRow & ")" .Range("z" & lastRow).Formula = "=IF(F" & lastRow & "=0,0,G" & lastRow & "-F" & lastRow & ")" .Range("aa" & lastRow).Formula = "=IF(E" & lastRow & "=0,0,Y" & lastRow & "+Z" & lastRow & ")" End With ' Call fillBorders(lastRow) Call formatCells(lastRow) lastRow = lastRow + 1 Next enginePosition End Sub