Excel VBA Games : Find Matches | Rocket Throwing | Tetris

Fun Games Created With Excel VBA Codes


        Simple and fun VBA games that can be played inside the Excel worksheet.
There are three games in three separate workbooks:

  1. Find Matches : In the game , you need to find the same colored cells by double-clicking on the cells.

  1. Rocket Throwing : Press "Enter" key, the rocket moves, and passes through the barriers with up-down keys and completes its movement smoothly.

  1. Tetris : The classic game was brought to life with VBA codes.



Read more ...

Excel Convert HEX To RGB

Excel VBA Convert HEX To RGB With Userform


          Hexadecimal(Hex) color codes frequently are used in web designing (HTML-CSS etc.) .
In Excel, the RGB and HLS color codes  are used. Therefore, it is necessary to convert Hex values to RGB or HLS.

          For example,consider we have a hexadecimal code for a cell background color in Excel ; #FF8800 . This code corresponds to orange color.When we convert this code to rgb with userform that we created, the result is RGB(255,136,0). So, we can use the color code as Rgb in Excel and VBA.

For example : Sheets("Page-1").Range("f11").Interior.Color = RGB(255, 136, 0)
                       TextBox1.BackColor = RGB(255, 136, 0)

excel hex to rgb


convert hex to rgb

Read more ...

Creating A Separate Sheet For Each Month With Macro

Excel VBA Create The Separate Sheet For Each Month

           When "Create Month Sheets" button in worksheet is clicked, new sheets (12 sheets) are created for each month and added in workbook.
Namely months of the current year are ordered as sheets.

📅 Days of each month are listed in Column A as "dd.mm.yyyy". Today's date is selected from between dates.

When the "Delete Sheets" button is pressed, the created 12 sheets are deleted.

vba create sheet for each month

The VBA codes we use to create the months:
Sub CreateMonths()
   Dim lDay As Long
   Dim iWks As Integer, iDay As Integer
   On Error Resume Next
   For iWks = 1 To 12
      Worksheets.Add after:=Worksheets(Worksheets.Count)
      ActiveSheet.Name = Format(DateSerial(1, iWks, 1), "mmmm")
       ActiveWorkbook.Worksheets.Application.Columns("A:A").ColumnWidth = 11
   'ActiveWorkbook.Worksheets.Application.Columns("A:A").EntireColumn.AutoFit
      For lDay = DateSerial(Year(Date), iWks, 1) To DateSerial(Year(Date), iWks + 1, 0)
         iDay = iDay + 1
         Cells(iDay, 1).Value = DateSerial(Year(Date), iWks, iDay)
      Next lDay
      iDay = 0
   Next iWks
  GotoToDay
  End Sub

Sub GotoToDay()
   Dim iRow As Integer
   Worksheets(Month(Date) + 1).Select
   iRow = WorksheetFunction.Match(CDbl(Date), Columns(1), 0)
   Cells(iRow, 1).Select
End Sub

In the above codes, the GotoToDay procedure is run to select today's date.

creating month sheet macro

Read more ...