Dynamic Code Issue

BrighJShane

New Member
Joined
Jul 7, 2017
Messages
4
Hi All,

Hope you are having a lovely run up to Christmas!

I am having an issue probably due to lack of experience. I have been coding for a few months and now i am having an issue with dynamic codes.

Essentially, here is my issue:

Column A are people's names.Column B shows their individual meal costs in the hotel's restaurant (i.e. Johns meal is £36, Annie's meal is £56 etc.). Column C shows the room number that individual belongs to (So Annie , john, Marc and Pedro are from room 5, Jacob and Victoria from room 6 etc.). The reason this is important is because dinner costs are added to the overall room bill. Column D shows whether the customer is a hotel guest or not (Simple yes/no).

I want the code to filter column B family by family(alphabetically) and IF column D is YES, dynamically calculate the TOTAL cost of the entire meal cost of that family from column B and if that total is less than 50, a minimum charge of 50 will be applied across the household evenly, meaning if the family has 4 people, each will get 12.50 in the column B for that family. Now, If its over £50, then whatever the amount is will be charged as it stands. This will then loop through each family until the end.


I hit a brick wall with this as i dont know how a dynamic code like that will look like. Any help will be appreciated. Merry christmas!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Filtering by name could be problematic since it is subject to being misspelled or inconsistently entered. It would be easier to filter on the room number for the hotel guests. Would the minimum charge also apply to people who are not hotel guests? How do you know the names of the people who are not hotel guests?

When i have a complex project to develop, I draw a simple flow chart showing the tasks that need to be completed and any decisions that must be made before or after that task. Each decision usually implies the need for an If...Then or a Select Case statement to get past the decision point and move to the next logical task. Once I have the chart worked out, the code is pretty easy to write by just following the flow in the chart. Trying to keep all that straight in your memory and write the code at the same time can be very confusing.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top