Sub ArraySlicing()
Dim arr(1 To 5, 1 To 5)
Dim slice
Dim x, y
Dim a As Application
'Populate a sample 2-D array with values...
For y = 1 To 5
For x = 1 To 5
arr(y, x) =
…
Posts Categorized: VBA
为了打开有中文名称的宏及Module,要Unselect this checkbox

VBA – How to auto fit row height of merged cells in Excel
How to auto fit row height of merged cells in Excel? (extendoffice.com)
Option Explicit
Public Sub AutoFitAll()
Call AutoFitMergedCells(Range("a1:b2"))
Call AutoFitMergedCells(Range("c4:d6"))
Call AutoFitMergedCells(Range("e1:e3"))
End Sub
Public Sub AutoFitMergedCells(oRange As Range)
Dim tHeight As Integer
Dim iPtr As Integer
Dim oldWidth
…
INDIRECT formula to dynamically refer to another worksheet ->INDIRECT(“‘” & Sheet’s name & “‘!” & Cell to pull data from)
Excel INDIRECT function – basic uses and formula examples (ablebits.com)…
Benefit for learning VBA
Unlike macros, VBA enables you to do the following:
- Work with complex logic structures (case statements, loops, and so on)
- Take advantage of functions and actions not available in macros
- Loop through and perform actions on recordsets
- Perform transaction processing
ParamArray
The ParamArray keyword allows you to accept a dynamic number of arguments.
The word ParamArray is an abbreviation for parameter array.
Instead of using a large number of optional parameters it might be better to use a parameter array instead.…