Heres a Challenge for anyone!


New Member
Aug 19, 2009
Hi guys. ive got a complicated one (i think)

if i have a hotel and the room rate is different for each calendar date bracket eg:

01 august - 15 august = £15
16 august - 30 august = £25

Is there a way i can get excel to calulate the price for the customers stay. for example if they were staying 10 August until 20 August.

your guidance and suggestions are very much welcome on this one.

thanks in advance



MrExcel MVP
Jan 9, 2008
Hi, Try this:- The code shows the principle , you will have to add details to the "Select Case" Dates/Costs.
[COLOR=navy]Sub[/COLOR] MG19Aug45
[COLOR=navy]Dim[/COLOR] Dts [COLOR=navy]As[/COLOR] [COLOR=navy]String,[/COLOR] Dt1 [COLOR=navy]As[/COLOR] Date, Dt2 [COLOR=navy]As[/COLOR] Date, Dt [COLOR=navy]As[/COLOR] Date, Cst [COLOR=navy]As[/COLOR] Double
[COLOR=navy]Dim[/COLOR] Tcs [COLOR=navy]As[/COLOR] Double
[COLOR=navy]On[/COLOR] [COLOR=navy]Error[/COLOR] [COLOR=navy]Resume[/COLOR] [COLOR=navy]Next[/COLOR]
 Dts = Application.InputBox(prompt:="Please Insert Inclusive dates :-" _
 & Chr(10) & "Example:- 10/8/2009-20/8/2009 ", _
        Title:="Insert Brackets", Type:=2)
[COLOR=navy]If[/COLOR] Dts = "False" [COLOR=navy]Then[/COLOR] [COLOR=navy]Exit[/COLOR] [COLOR=navy]Sub[/COLOR]
    Dt1 = Split(Dts, "-")(0)
        Dt2 = Split(Dts, "-")(1)
[COLOR=navy]For[/COLOR] Dt = Dt1 To Dt2
    [COLOR=navy]Select[/COLOR] [COLOR=navy]Case[/COLOR] Dt
        [COLOR=navy]Case[/COLOR] "1/8/2009" To "15/8/2009": Cst = 15
        [COLOR=navy]Case[/COLOR] "16/8/2009" To "30/8/2009": Cst = 25
        [COLOR=navy]End[/COLOR] Select
            Tcs = Tcs + Cst
[COLOR=navy]Next[/COLOR] Dt
MsgBox "Cost for inclusive dates :- " & Chr(10) & Dts & " = £" & Tcs
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
Last edited:

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...