VBA-Excel: Arrays – One Dimension, Dynamic Array

Dynamic array means when size of the array is not fixed at the start of the program,  the size changes dynamically.

Use ReDim, For Resizing the size of the array.

If you just you ReDim to changing the size of an array, the already stored values in array will be deleted, if you want to keep the old values of an array while resizing the array, use Presereve keyword along with ReDim

ReDim Preserve arrArrayName(newSize)

Example: Store all the available values in column A, into an Array.

For creating one dimensional static array, follow the below steps

  • Declare an Array
  • Resize the array
  • Store values in array
  • Retrieve values from array.

Read moreVBA-Excel: Arrays – One Dimension, Dynamic Array

VBA-Excel: Create Dynamic or Run-time WorkSheets using Macro.

To Create Dynamic or Run-time WorkSheets using Macro, follow the steps mentioned below

Steps:

  • Get the Active WorkBook object
  • Add the worksheets at the run time using Add().Name() method

 

Get the Active WorkBook object

        Set mainWorkBook = ActiveWorkbook

Add the worksheets at the run time using Add().Name() method

Read moreVBA-Excel: Create Dynamic or Run-time WorkSheets using Macro.

VBA-Excel: SUDOKU Solver

Download Link : SUDOKU Solver

Steps:

  • Open a new WorkBook
  • Create a SUDOKU template
  • Create a Button
  • Copy Paste the Complete Code
  • Press the button till the SUDOKU is solved.

Note: This Code works only for easy and medium level SUDOKU problems

 

After Creating the SUDOKU template you page should look like this:

NOTE: Make sure you create the template in correct cells else you will have to change the code

Create a SUDOKU template

SUDOKU SOLVER-1
SUDOKU SOLVER-1

Read moreVBA-Excel: SUDOKU Solver