+ Reply to Thread
Results 1 to 11 of 11

Booking system

Hybrid View

_Gandour_ Booking system 08-25-2016, 02:40 PM
AlphaFrog Re: Booking system 08-25-2016, 04:53 PM
_Gandour_ Re: Booking system 08-26-2016, 09:51 AM
AlphaFrog Re: Booking system 08-26-2016, 09:55 AM
_Gandour_ Here it is :) 08-26-2016, 10:07 AM
AlphaFrog Re: Booking system 08-26-2016, 10:35 AM
_Gandour_ Re: Booking system 08-26-2016, 11:57 AM
_Gandour_ Re: Booking system 08-26-2016, 12:04 PM
AlphaFrog Re: Booking system 08-26-2016, 12:18 PM
AlphaFrog Re: Booking system 08-26-2016, 12:03 PM
_Gandour_ Re: Booking system 08-26-2016, 12:05 PM
  1. #1
    Registered User
    Join Date
    08-22-2016
    Location
    RN, Brasil
    MS-Off Ver
    2007
    Posts
    6

    Booking system

    Hey guys, first time posting, straight from work.

    My boss wants me to elaborate a conference room booking system for events at the office, right away i saw that it could not be done only through formula, so i broke the immaginary wall and started messing with macros for the first time.

    Here is what i managed to do so far: A table in wich you can select the room and the date through a dropdown list as well as other information. If local and date are not equal to previous entries, it copies the information to another sheet ("Database")

    But thing is i dont know hot to do whats next.

    I made this stupid calendar besides the table:

    print.png

    What i want to do is that when i select the local through the drop down list it runs a macro that looks for Local (A:A) and Date (B:B) in the Database sheet and highlight on the calendar the dates in wich the rooms are occupied.

    Do u guys have any idea how can i do that?

    OBS:Besides showing only day numbers inside the cell because of formating, the cells actually contain the date in dd/mm/yyyy format.
    Last edited by _Gandour_; 08-26-2016 at 01:20 PM. Reason: Problem solved

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Booking system

    Try something like this (not tested)

    Sub Ocupado()
        Dim cell As Range, rngCalandarDate As Range
        'Clear previous date highlights
        ActiveSheet.Range("F6:AJ11,F15:AJ20,F24:AJ29").Interior.ColorIndex = xlNone
        With Sheets("Database")
            If .FilterMode Then .ShowAllData
            'Filter the database for local
            .Range("A:B").AutoFilter Field:=1, Criteria1:=ActiveSheet.Range("C6").Value
            'Loop through each local date if any
            If .Range("B" & Rows.Count).End(xlUp).Row > 1 Then
                For Each cell In .Range("B2", .Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible)
                    'Highlight matched dates on the calandar
                    Set rngCalandarDate = ActiveSheet.Range("F6:AJ29").Find(cell.Value, , xlFormulas, xlWhole)
                    If Not rngCalandarDate Is Nothing Then
                        rngCalandarDate.Interior.Color = vbYellow
                    End If
                Next cell
            End If
            If .FilterMode Then .ShowAllData
        End With
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-22-2016
    Location
    RN, Brasil
    MS-Off Ver
    2007
    Posts
    6

    Re: Booking system

    Strangely, nothing really happens, not even an error message

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Booking system

    Quote Originally Posted by _Gandour_ View Post
    Strangely, nothing really happens, not even an error message
    Can you attach an example workbook.

  5. #5
    Registered User
    Join Date
    08-22-2016
    Location
    RN, Brasil
    MS-Off Ver
    2007
    Posts
    6
    Quote Originally Posted by AlphaFrog View Post
    Can you attach an example workbook.
    Here it is
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Booking system

    Try this...

    Sub Ocupado()
        Dim cell As Range, rngCalandarDate As Range
        'Clear previous date highlights
        Range("F6:AJ11,F15:AJ20,F24:AJ29").Interior.ColorIndex = xlNone
        With Sheets("Database")
            If .FilterMode Then .ShowAllData
            'Filter the database for local
            .Range("A:B").AutoFilter Field:=1, Criteria1:=Range("C6").Value
            'Loop through each local date if any
            If .Range("B" & Rows.Count).End(xlUp).Row > 1 Then
                For Each cell In .Range("B2", .Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible)
                    'Highlight matched dates on the calandar
                    Set rngCalandarDate = Range("F6:AJ29").Find(DateValue(cell.Value2), , xlFormulas, xlWhole)
                    If Not rngCalandarDate Is Nothing Then
                        rngCalandarDate.Interior.Color = vbYellow
                    End If
                Next cell
            End If
            If .FilterMode Then .ShowAllData
        End With
    End Sub

  7. #7
    Registered User
    Join Date
    08-22-2016
    Location
    RN, Brasil
    MS-Off Ver
    2007
    Posts
    6

    Re: Booking system

    Wow, that works, thank you so much!!!

    Just made a little change so it would clear the filter and not interfere with other macros.

    Sub Ocupado2()
        Dim cell As Range, rngCalandarDate As Range
        'Clear previous date highlights
        Range("F6:AJ11,F15:AJ20,F24:AJ29").Interior.ColorIndex = xlNone
        With Sheets("Database")
            If .FilterMode Then .ShowAllData
            'Filter the database for local
            .Range("A:B").AutoFilter Field:=1, Criteria1:=Range("C6").Value
            'Loop through each local date if any
            If .Range("B" & Rows.Count).End(xlUp).Row > 1 Then
                For Each cell In .Range("B2", .Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible)
                    'Highlight matched dates on the calandar
                    Set rngCalandarDate = Range("F6:AJ29").Find(DateValue(cell.Value2), , xlFormulas, xlWhole)
                    If Not rngCalandarDate Is Nothing Then
                        rngCalandarDate.Interior.Color = vbYellow
                    End If
                Next cell
            End If
            If .FilterMode Then .ShowAllData
        Sheets("Database").Activate
        'So it can clear the filter at the end
        Cells.AutoFilter
        Sheets("Sistema").Activate
        End With
    End Sub

  8. #8
    Registered User
    Join Date
    08-22-2016
    Location
    RN, Brasil
    MS-Off Ver
    2007
    Posts
    6

    Re: Booking system

    If Anyone wonders how i was able to use the dropdown as the macro activator: here it is (Dont know if its the best way)


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("c6")) Is Nothing Then
        Select Case Range("c6")
            '"Local name": Macro name
            Case "Salão Nobre": Ocupado2
            Case "Auditório": Ocupado2
            Case "Sala de Treinamento 1": Ocupado2
            Case "Sala de Treinamento 2": Ocupado2
            Case "Laboratório de Informática": Ocupado2
        End Select
    End If
    End Sub

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Booking system

    Quote Originally Posted by _Gandour_ View Post
    If Anyone wonders how i was able to use the dropdown as the macro activator: here it is (Dont know if its the best way)


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("c6")) Is Nothing Then
        Select Case Range("c6")
            '"Local name": Macro name
            Case "Salão Nobre": Ocupado2
            Case "Auditório": Ocupado2
            Case "Sala de Treinamento 1": Ocupado2
            Case "Sala de Treinamento 2": Ocupado2
            Case "Laboratório de Informática": Ocupado2
        End Select
    End If
    End Sub
    The Data Validation only allows a cell value from the list. This should work as well (not tested).

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$C$6" And Target(1).Value <> "" Then Ocupado2
    End Sub

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Booking system

    You're welcome.

    Put headers in row 1 of the Database sheet. The .Autofilter assumes the top row of the filter range is a header.

  11. #11
    Registered User
    Join Date
    08-22-2016
    Location
    RN, Brasil
    MS-Off Ver
    2007
    Posts
    6

    Re: Booking system

    Quote Originally Posted by AlphaFrog View Post
    You're welcome.

    Put headers in row 1 of the Database sheet. The .Autofilter assumes the top row of the filter range is a header.
    Yeah, did that. Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Good in booking system
    By donkey_uk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-08-2016, 12:04 PM
  2. Basic Booking System Help!
    By Squire90 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-08-2015, 10:20 AM
  3. Job Booking in system
    By Shieldzy13 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-28-2013, 12:21 PM
  4. Trying to Create a booking in and out system
    By ellisp999 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2013, 06:26 PM
  5. Creating a booking system
    By harley08 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-14-2008, 05:50 PM
  6. booking system.
    By redja in forum Excel General
    Replies: 4
    Last Post: 02-21-2007, 10:45 AM
  7. Booking system formula
    By johncouzins in forum Excel General
    Replies: 4
    Last Post: 07-26-2005, 11:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1