YUKIBEのBLOG

日常のメモ書き

Excel:VBA:セル(Range):特別なセル(空白etc)

空白セル

Sub testRng_空白セル()

On Error GoTo ErrHandl
  Selection.SpecialCells(xlCellTypeBlanks) = "GG"

Exit Sub

ErrHandl:
  If Err.Number = 1004 Then '
    Err.Clear
  End If
  
End Sub

Public Function getRng_空白セル(rng As Range) As Range

  Set getRng_空白セル = rng.SpecialCells(xlCellTypeBlanks)


End Function

Sub testRng_数式セル()

  Dim rng As Range
  Set rng = Cells.SpecialCells(xlCellTypeFormulas)
  
  Dim vFE
  For Each vFE In rng
    Debug.Print vFE.Formula, vFE.Address
  Next vFE
  
End Sub