Skip to content

Instantly share code, notes, and snippets.

@ganesh092929
ganesh092929 / Tut2-DebugPrint.xlsm
Created December 25, 2017 08:57
Tutorial 2 Debug Print
Sub Test()
Debug.Print "Hello World"
End Sub
@ganesh092929
ganesh092929 / Tut2-SubTemplate.xlsm
Last active December 25, 2017 08:58
Sub Routine Template
Sub Test()
<statement>
End Sub()
@ganesh092929
ganesh092929 / Tut2-Variables.xlsm
Last active December 25, 2017 09:03
Introducing Variables
Sub Test()
'Dim variableName as variableType
Dim int1 as Integer
Dim str1 as String
int1 = 1
str1 = "Hello World"
Debug.print int1
Debug.print str1
Sub ExtractValues()
Debug.Print Cells(1, 1).Value
Debug.Print Cells(2, 1).Value
End Sub
Sub WriteValues()
Cells(1, 2).Value = "Hello"
Cells(2, 2).Value = "World"
End Sub
Sub StringConcat()
Cells(3,1).Value = Cells(1, 1).Value & " " & Cells(2, 1).Value
End Sub
Sub IfConditions()
If <condition> then
<statement>
Elseif <condition> then
<statement>
Else
<statement>
End If
End Sub
Sub IfName()
Dim strName As String
strName = "Alex"
If strName = "John" Then
Debug.Print "Welcome Back" + strName
Else
Debug.Print "Hello " + strName
End If
End Sub
Sub ForLoop()
For i = 1 To 10
debug.print i
Next i
End Sub
Sub AllRowValues()
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastRow
Debug.Print Cells(i, 1).Value
Next i
End Sub