Skip to content

clearcells

Clear cell contents while preserving the cells themselves.

clearcells(crDst)
clearcells(crDst, role)

Clears the data in crDst but keeps the rows and columns intact. The optional role string selects what to clear (default clears values):

  • 'ValueRole' — cell values (default)
  • 'FormulaRole' — formulas only
  • 'FormatRole' — formatting / styles
  • 'CommentRole' — comments
  • …and other CellDataRole names
clearcells(A1:C10) % clear values
clearcells(A1:C10, 'FormatRole') % clear formatting only
  • deletecells — Delete cells, shifting remaining cells.
  • copycells — Copy a cell range, optionally to a destination range.