File: vba_test.vba

package info (click to toggle)
cloc 2.08-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,304 kB
  • sloc: perl: 30,693; cpp: 1,219; python: 623; ansic: 334; asm: 267; makefile: 244; sh: 186; sql: 144; java: 136; ruby: 111; cs: 104; xml: 61; pascal: 52; lisp: 50; cobol: 35; haskell: 35; f90: 35; objc: 25; php: 22; javascript: 15; fortran: 9; ml: 8; tcl: 2
file content (22 lines) | stat: -rw-r--r-- 565 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Attribute VB_Name = "Module1"
' VBA (Visual Basic for Applications) example
' This would typically be found in Excel, Word, or Access

Option Explicit

Sub HelloWorld()
    ' This is a VBA subroutine
    MsgBox "Hello from VBA!"
End Sub

Function AddNumbers(x As Integer, y As Integer) As Integer
    ' VBA function to add two numbers
    AddNumbers = x + y
End Function

Private Sub Worksheet_Change(ByVal Target As Range)
    ' Event handler - typical in VBA
    If Target.Address = "$A$1" Then
        Range("B1").Value = "Cell A1 was changed"
    End If
End Sub