- Home
- Blog
- Bowie State University Excel Project
- Set up.
- Create a new Excel file and save it as a macro-enabled file Final_YourLastName_YourFirstName.xlsm.
- Rename Sheet1 to Poker.
- Switch to VBA Editor.
- Rename Sheet1 to SheetPoker.
- Insert a new standard module and rename Module1 to ModulePoker.
- Create three buttons.
- Switch to worksheet Poker.
- Create a button occupying range A2:B3.
- Add new macro name: ButtonDeal_Click.
- Store macro in: This Workbook.
- Switch to worksheet and rename button text to Deal.
- Create a button occupying range A4:B5.
- Add new macro name: ButtonSort_Click.
- Store macro in: This Workbook.
- Switch to worksheet and rename button text to Sort.
- Create a button occupying range A6:B7.
- Add new macro name: ButtonClear_Click.
- Store macro in: This Workbook.
- Switch to worksheet and rename button text to Clear.
- Set up lookup table onto columns G, H and I.
- Lower = 1, Upper = 13, Suit = Spade.
- Lower = 14, Upper = 26, Suit = Heart.
- Lower = 27, Upper = 39, Suit = Diamond.
- Lower = 40, Upper = 52, Suit = Club.
- Name this range LookUpSuit.
- Set up lookup table onto columns K and L.
- Mod = 0, Rank = Ace.
- Mod = 1, Rank = 2.
- Mod = 2, Rank = 3.
- Mod = 3, Rank = 4.
- Mod = 4, Rank = 5.
- Mod = 5, Rank = 6.
- Mod = 6, Rank = 7.
- Mod = 7, Rank = 8.
- Mod = 8, Rank = 9.
- Mod = 9, Rank = 10.
- Mod = 10, Rank = Jack.
- Mod = 11, Rank = Queen.
- Mod = 12, Rank = King.
- Name this range LookUpRank.
- Write comments for every macro and every code block below.
- Switch to VBA Editor.
- Implement click event handler ButtonDeal_Click.
- Set range C1 value to Random, and change it to bold style.
- Set range D1 value to Suit, and change it to bold style.
- Set range E1 value to Rank, and change it to bold style.
- On range C2:C6, generate random integers between 1 and 52, then copy and paste by values onto the range itself.
- On range D2:D6, use the value on column C to look up the Suit value in the lookup table on range LookUpSuit.
- On range E2:E6, use the remainder of the value on column C divided by 13to look up the Rank value in the lookup table on range LookUpRank.
- Start on range C1 to include all connected data cells, and name the whole data range as Cards.
- Set the horizontal alignment in range Cards to Center.
- Implement click event handler ButtonSort_Click.
- Sort range Cards by ascending order on column C.
- Implement click event handler ButtonClear_Click.
- Clear all contents and formats on range Cards (or columns C, D and E).
- Save, attach and submit your completed Excel file.
- Your complete worksheet Poker would be:
0 comments