Commands Description
  ActiveCell.CurrentRegion.Select Select a range or block of data (Cells). Keep columns to the left and right clear of data so that they are not apart of the block.
  Selection.End(xlDown).Select
End down
  ActiveCell.Offset(1, 0).Select offset (Row, Col)
  ActiveSheet.DisplayPageBreaks = False Removes dotted print lines
  Application.DisplayAlerts = False Turn alert alerts On (=True) or Off (=False) example
  Application.ScreenUpdating = False This is used so that you do not see the macro run. It makes the macro go faster.
Note if you use this the cursor will not follow you to the new cell.
  Application.CutCopyMode = False This is like pressing “Esc” to get rid of the rubber band box. Use this after you have pasted your data.
  ActiveWorkbook.Save
ActiveWorkbook.Close Savechanges:=True
This will save the workbook
This will close and save the workbook
  ActiveCell.EntireColumn.AutoFit Adjust current column width
  ActiveCell.EntireColumn.Copy copy active column
  Sheets("Sheet3").Select Go to sheet 3
  [a1].Select Go to a Cell location - If using screen updating the cursor will not follow to active cell
  Range("A1:D20").Select Select a Range of cells
  Selection.Copy Copy Active Selection
  ActiveSheet.Paste Paste data to ActiveCell
  vbCrLf replace with VBNEWLINE
This will add a Carrage Return in VBA used to start a new line of data
MsgBox = "First Line & vbCrLf & Second Line"
  Turn on and off the caluculation function Application.Calculation = xlManual
Application.Calculation = xlAutomatic
  Minus Minus in front of a formula.
     =IsNumber( ) ' would result in either True or False

     =--IsNumber( ) ' would result in either 0 or 1
=ISNUMBER(IFERROR(SEARCH($B$3,E3,1),""))
Would result in either True or False
=--ISNUMBER(IFERROR(SEARCH($B$3,E3,1),""))
Would result in either 0 or 1
  How to add a Key Stroke to activate a macro. Click Developer tab / click on Macros / click Options

w3School web site               

BAR Codes using excel

Substitute Split Numbers and Letters in a Serial number



In this example the serial number LT100000001 is located in cell A1
Cell B1 will contain the following formula:
[B1].Formula = "=(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,""0"",""""),""1"",),""2"",),""3"",),""4"",),""5"",),""6"",),""7"",),""8"",),""9"",))"
Cell C1 will contain the following formula:
[C1].Formula = "=VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,""A"",""""),""E"",),""Q"",),""P"",),""S"",),""F"",),""J"",),""L"",),""N"",),""T"",))"
Note that the serial number is text so we add VALUE to the Statement. The word SUBSTITUTE is used for each letter to substitute starting in (A1,""A"","""") then all other substitutes ,""E"",)

Find_and_Goto_and_Find_Again

Sub FindNext()
Application.ScreenUpdating = False

Dim rng As Range
Set rng = Range("D:D")
Dim I, U, Y As Variant

U = Application.WorksheetFunction.CountIf(rng, "Dog")
For I = 1 To U
Set rng = Cells.Find(What:="Dog", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)

If Not rng Is Nothing Then
rng.Select
U = ActiveCell.Row

Y = Cells(U, 6)
' MsgBox Y ' this just confirms the value of the offset and is not needed
'Else
' MsgBox "not found"
End If
Next I
End Sub


Move data from one workbook to another workbook

Sub DB()
Dim A, B, C, D, E, F, G, H, i, J, K, L, LP, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z As String
Dim dt As Date
dt = Date
Dim DB1 As Workbook
Dim DB As Workbook
Set DB = Workbooks.Open("L:\AMC_TestResults\OpticTesting\OpticTestingR8.1.xlsm")

A = Cells(2, 1) 'invoice
B = Cells(1, 3) 'StockID
Dim RNG As Range
Set RNG = Range("B:B")
Z = Application.WorksheetFunction.CountIf(RNG, "Xcvr") + 7
C = Range(Cells(8, 5), Cells(Z, 6)).Copy 'SN and PN
Cells(8, 1).Select

Do Until (ActiveCell = "Physical")
ActiveCell.End(xlDown).Select
Loop
D = ActiveCell.Offset(23, 11)
E = ActiveCell.Offset(24, 11)
F = ActiveCell.Offset(27, 11)
G = ActiveCell.Offset(28, 11)
H = ActiveCell.Offset(37, 8)
i = ActiveCell.Offset(38, 8)
J = ActiveCell.Offset(52, 8)
K = ActiveCell.Offset(53, 8)
L = ActiveCell.Offset(67, 8)
M = ActiveCell.Offset(68, 8)
N = ActiveCell.Offset(82, 8)
O = ActiveCell.Offset(83, 8)

Set DB1 = Workbooks.Open("L:\AMC_TestResults\OpticTesting\TestingDB.xlsm")

DB1.Sheets("Home").Range("A1").End(xlDown).Offset(1) = dt
DB1.Sheets("Home").Range("B1").End(xlDown).Offset(1) = A
DB1.Sheets("Home").Range("C1").End(xlDown).Offset(1) = B
DB1.Sheets("Home").Range("D1").End(xlDown).Offset(1).PasteSpecial
DB1.Sheets("Home").Range("F1").End(xlDown).Offset(1) = D
DB1.Sheets("Home").Range("G1").End(xlDown).Offset(1) = E
DB1.Sheets("Home").Range("H1").End(xlDown).Offset(1) = F
DB1.Sheets("Home").Range("I1").End(xlDown).Offset(1) = G
DB1.Sheets("Home").Range("J1").End(xlDown).Offset(1) = H
DB1.Sheets("Home").Range("K1").End(xlDown).Offset(1) = i
DB1.Sheets("Home").Range("L1").End(xlDown).Offset(1) = J
DB1.Sheets("Home").Range("M1").End(xlDown).Offset(1) = K
DB1.Sheets("Home").Range("N1").End(xlDown).Offset(1) = L
DB1.Sheets("Home").Range("O1").End(xlDown).Offset(1) = M
DB1.Sheets("Home").Range("P1").End(xlDown).Offset(1) = N
DB1.Sheets("Home").Range("Q1").End(xlDown).Offset(1) = O
Cells(2, 4).End(xlDown).Offset(0, -3).Select
If ActiveCell <> "" Then
GoTo line1
End If
Cells(2, 4).End(xlDown).Offset(0, -3).Select
Range(Selection, Selection.End(xlUp)).FillDown
ActiveCell.Offset(0, 1).Select
Range(Selection, Selection.End(xlUp)).FillDown
ActiveCell.Offset(0, 1).Select
Range(Selection, Selection.End(xlUp)).FillDown
ActiveCell.Offset(0, 3).Select
For T = 1 To 12
ActiveCell.End(xlUp).Offset(1) = "."
Range(Selection, Selection.End(xlUp)).FillDown
ActiveCell.Offset(0, 1).Select
Next T
Do Until (ActiveCell = "")
Cells(3, 6).Select
If ActiveCell <> "." Then
ActiveCell.Interior.ColorIndex = 4
ActiveCell.Offset(1).Select
End If
Loop [A1].Select line1: End Sub

Find Next Tx

Find Cell by color