Untitled
unknown
plain_text
a year ago
3.2 kB
9
Indexable
Sub AssignSeatsByClassAndSection()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1") ' Adjust this to your sheet name
Dim currentRow As Long
Dim ticketClass As String
Dim seatSection As String
Dim seatRow As String
Dim seatNumber As Integer
Dim maxSeats As Integer
' Define seating structure
Dim seatsPerRow As Integer
seatsPerRow = 10 ' Assuming 10 seats per row as per venue seating image. Adjust this as needed.
' Seat distribution
Dim executiveRow As String: executiveRow = "B"
Dim premiumRows As Variant: premiumRows = Array("D", "E")
Dim eliteRows As Variant: eliteRows = Array("F", "G", "H")
Dim selectRows As Variant: selectRows = Array("I", "K", "J", "L", "M", "N", "O", "P", "Q", "R")
' Initialize row for reading tickets
currentRow = 2 ' Assuming the data starts in row 2
' Loop through tickets and assign seats
Do While ws.Cells(currentRow, 1).Value <> ""
ticketClass = ws.Cells(currentRow, 1).Value ' Assuming the class is in column A
If ticketClass = "Executive" Then
AssignSeats ws, executiveRow, seatsPerRow, "Center"
ElseIf ticketClass = "Premium" Then
AssignSeatsByRows ws, premiumRows, seatsPerRow, currentRow
ElseIf ticketClass = "Elite" Then
AssignSeatsByRows ws, eliteRows, seatsPerRow, currentRow
ElseIf ticketClass = "Select" Then
AssignSelectSeats ws, selectRows, seatsPerRow, currentRow
End If
currentRow = currentRow + 1
Loop
End Sub
Sub AssignSeats(ws As Worksheet, row As String, seatsPerRow As Integer, section As String)
Dim seatNumber As Integer
Dim seatAssigned As Boolean
seatAssigned = False
' Assign center seats first
If section = "Center" Then
For seatNumber = seatsPerRow / 2 - 1 To seatsPerRow / 2
If ws.Cells(seatNumber, 4).Value = "" Then
ws.Cells(seatNumber, 4).Value = row & seatNumber
seatAssigned = True
Exit For
End If
Next seatNumber
End If
End Sub
Sub AssignSeatsByRows(ws As Worksheet, rows As Variant, seatsPerRow As Integer, currentRow As Long)
Dim i As Integer
Dim row As String
For i = LBound(rows) To UBound(rows)
row = rows(i)
AssignSeats ws, row, seatsPerRow, "Center"
' Add left-right logic if needed after center
Next i
End Sub
Sub AssignSelectSeats(ws As Worksheet, rows As Variant, seatsPerRow As Integer, currentRow As Long)
Dim i As Integer
Dim row As String
' Fill center of row I, K first
For i = LBound(rows) To UBound(rows)
row = rows(i)
If row = "I" Or row = "K" Then
AssignSeats ws, row, seatsPerRow, "Center"
End If
Next i
' Then assign left-right seats for those rows
For i = LBound(rows) To UBound(rows)
row = rows(i)
If row = "I" Or row = "K" Then
AssignSeats ws, row, seatsPerRow, "Left"
AssignSeats ws, row, seatsPerRow, "Right"
End If
Next i
End SubEditor is loading...
Leave a Comment