Hoping somebody can help with this. My knowledge of VBA is almost non-existent so apologies if I haven't explained things very well!
I've created a booking system and need 2 macros to perform multiple tasks. I've uploaded a couple of images which may help.
BOOK button on Sheet1 when clicked:
1. Check if the desk reference, date and name fields have been entered. If any of these are blank then a message box will appear saying so. If they are all populated then go to step 2...
2. Check if the booking reference generated in cell AA22 is already in column A of Sheet2. If yes then a message box "Desk already booked for date selected. Please choose again." If it isn't already in column A of Sheet 2 then go to step 3...
3. Copies the desk booking reference in cell AA22 and the name in cell AA15 and pastes them to the next available row in columns A and B respectively on Sheet2 then clears the contents in cells AA7, AA11 and AA15 on Sheet1. Message box "Your booking reference is [booking reference]. Please remember this as you will need it if you need to cancel your booking."
Here's what code I already have for the above which is essentially part of step 3. My knowledge doesn't stretch to adding in the other steps.
CANCEL button on Sheet1 when clicked:
Looks for the booking reference in column A on Sheet2 and clears the cell (plus clears the corresponding name in column B if possible). Message box "Your booking has been cancelled." Clears cell BC15 on Sheet1.
I've created a booking system and need 2 macros to perform multiple tasks. I've uploaded a couple of images which may help.
BOOK button on Sheet1 when clicked:
1. Check if the desk reference, date and name fields have been entered. If any of these are blank then a message box will appear saying so. If they are all populated then go to step 2...
2. Check if the booking reference generated in cell AA22 is already in column A of Sheet2. If yes then a message box "Desk already booked for date selected. Please choose again." If it isn't already in column A of Sheet 2 then go to step 3...
3. Copies the desk booking reference in cell AA22 and the name in cell AA15 and pastes them to the next available row in columns A and B respectively on Sheet2 then clears the contents in cells AA7, AA11 and AA15 on Sheet1. Message box "Your booking reference is [booking reference]. Please remember this as you will need it if you need to cancel your booking."
Here's what code I already have for the above which is essentially part of step 3. My knowledge doesn't stretch to adding in the other steps.
VBA Code:
Sub Button1_Click()
ws_output = "BOOKINGS"
next_row = Sheets(ws_output).Range("A" & Rows.Count).End(xlUp).Offset(1).Row
Sheets(ws_output).Cells(next_row, 1).Value = Range("bookref_book").Value
Sheets(ws_output).Cells(next_row, 2).Value = Range("name_book").Value
Range("Z112:AU114").ClearContents
Range("Z116:AU118").ClearContents
Range("Z120:AU122").ClearContents
MsgBox "Your booking reference is XXX-XXXXXX. Please keep a note of this reference as you will need it to cancel your booking", vbOKOnly + vbInformation, ""
End Sub
CANCEL button on Sheet1 when clicked:
Looks for the booking reference in column A on Sheet2 and clears the cell (plus clears the corresponding name in column B if possible). Message box "Your booking has been cancelled." Clears cell BC15 on Sheet1.