What is the syntax to select cells?

To select a single cell

Range("<Cell Value>").Select
(ex) Range("A1").Select
(ex) Range("C3").Select

 

To select a continuous range

Range("<Cell Value>").Select
(ex) Range("A1:B4").Select
(ex) Range("C3:F400").Select

 

To select multiple non-continuous ranges

Range("<Cell Value>, <Cell Value>").Select
(ex) Range("A1:E3, H2:H44").Select
(ex) Range("C3:D4, Y3:Y4").Select

 

To select down to the 1st empty cell

Range(Selection, Selection.End(xlDown)).Select

toselectdowntofirstemptycell

Advertisements

What is the syntax for Do Loops?

Do While <condition>
    [ statements ]
Loop
Do Until <condition>
    [ statements ]
Loop
Do
[ statements ]
Loop While <condition>
Do
[ statements ]
Loop Until <condition>

What is the syntax for adding a worksheet?

'to add a sheet at the very beginning of the Sheets tab
Worksheets.Add Before:=Worksheets(1)

'to add a sheet at the very beginning of the Sheets tab
Dim shtLast As Worksheet
Set shtLast = .Worksheets(.Worksheets.Count)
Set shtNew = Worksheets.Add(After:=shtLast)

'to add multiple sheets before the active sheet
ThisWorkbook.Worksheets.Add Count:=<number of sheets you want to add>

'to add a new sheet before the current active sheet
Dim sht as Worksheet
Set sht = ThisWorkbook.Worksheets.Add
sht.Name = "<name of new worksheet>"

 

 

Where can I access VBA?

All versions of Excel automatically hides access to VBA tools. To access it, follow the steps below:

  1. File (located in top Ribbon) > Options (located in left navigation bar) > Customize Ribbon (listed on left-hand side) > Check box the “Developer tab” > Click OK
  2. Go to the Developer tab; listed on the very left of the ribbon pane, you will see an icon labeled Visual Basic.

Capture

Capture2

Capture3.JPG

Capture4