What is VBA?
Example:
Sub HelloWorld()
MsgBox "Hello, World!"
End Sub
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。
了解热门 VBA 面试题与答案,帮助应届生和有经验的候选人为求职面试做好准备。
了解热门 VBA 面试题与答案,帮助应届生和有经验的候选人为求职面试做好准备。
搜索问题以查看答案。
Example:
Sub HelloWorld()
MsgBox "Hello, World!"
End Sub
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Dim myVar As String
myVar = "Hello"
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets(1)
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Dim cell As Range
For Each cell In Range("A1:A10")
Debug.Print cell.Value
Next cell
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
'Option Explicit
Sub Example()
Dim x As Integer
y = 10 ' This will cause an error without 'Option Explicit'
End Sub
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Sub Example()
If condition Then
Exit Sub
End If
' Rest of the code
End Sub
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Sheets.Add After:=Sheets(Sheets.Count)
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
If x > 10 Then
Debug.Print "x is greater than 10"
ElseIf x < 10 Then
Debug.Print "x is less than 10"
Else
Debug.Print "x is equal to 10"
End If
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Do While i < 10
Debug.Print i
i = i + 1
Loop
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Const PI As Double = 3.14159
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
On Error Resume Next
' code that may cause an error
On Error GoTo 0
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
For i = 1 To 10
Debug.Print i
Next i
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
MsgBox "Hello, World!", vbInformation + vbOKOnly, "Greeting"
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Call MyProcedure()
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Dim myArray(1 To 3) As Integer
myArray(1) = 10
myArray(2) = 20
myArray(3) = 30
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Dim userInput As String
userInput = InputBox("Enter your name:", "User Input")
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Application.ScreenUpdating = False
' Your code here
Application.ScreenUpdating = True
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Sub ModifyValue(ByRef x As Integer)
x = x + 1
End Sub
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
On Error Resume Next
' code that may cause an error
On Error GoTo 0
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
With Range("A1")
.Value = 42
.Font.Bold = True
End With
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
ActiveCell.Value = "Hello"
Selection.Font.Bold = True
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Sub ShowUserForm()
UserForm1.Show
End Sub
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Application.ScreenUpdating = False
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
' Code to execute when cells in A1:A10 are changed
End If
End Sub
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Select Case x
Case 1
Debug.Print "Value is 1"
Case 2
Debug.Print "Value is 2"
Case Else
Debug.Print "Value is neither 1 nor 2"
End Select
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
ActiveCell.Offset(1, 2).Value = "Data"
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Unload UserForm1
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Dim myArray(1 To 10) As Integer
Debug.Print LBound(myArray) ' Outputs 1
Debug.Print UBound(myArray) ' Outputs 10
收藏此条目、标记为困难题,或将其加入复习集合。
Example:
Function AddNumbers(x As Integer, y As Integer) As Integer
AddNumbers = x + y
End Function
收藏此条目、标记为困难题,或将其加入复习集合。