(1) VBA foundation

Common data types

  • Byte (byte)
  • Integer (int)
  • Long (long integer)
  • SINGLE (single-precision floating-point, seven significant digits)
  • Double (double precision floating point, 15 significant digits)
  • String (String)
  • Object type (e.g., a range of cells and worksheets Cells Range)
  • Variant (Variant, also called universal type)


Record Macro

Changing the fill color of the cell

Sub changing cell fill color ()
     With Selection.Interior 
        .Pattern = xlPatternSolid 
        .color = 65535 
        .TintAndShade = 0 
        .PatternColorIndex = - 4105 
    End  With 
End Sub

Set Row Height

Sub High setting line () 
    Selection.EntireRow.Select   ' select an entire row 
    Selection.RowHeight = 20 is     ' set the row height 
End Sub

When you click the button, set the value of a cell

Private Sub CommandButton1_Click()
    Sheets("表1").Range("a1:a10").Value = 666
End Sub

 

Guess you like

Origin www.cnblogs.com/lfjn/p/11415458.html
Recommended