zaro

What is GET.CELL in Excel?

Published in Excel Macro Function 2 mins read

GET.CELL is an Excel 4 macro function, not a standard worksheet function. This means you can't use it directly within a regular Excel formula in a cell. It's used within Visual Basic for Applications (VBA) macros to retrieve information about a cell. The function retrieves various properties of a cell, specified by a type_num argument, at a given reference.

Understanding GET.CELL

The GET.CELL function operates with a specific syntax: GET.CELL(type_num, reference).

  • type_num: A numerical code indicating the type of cell information you want. Different numbers return different properties (e.g., font color, number format, cell contents, etc.). A comprehensive list of type_num values isn't consistently available in readily accessible documentation, highlighting the function's specialized and less commonly used nature. Refer to the provided references for examples like the type_num of 0 for no page break.
  • reference: A cell reference (e.g., A1, B2:C5) specifying the cell whose properties you want to retrieve.

Examples of GET.CELL Use (Within VBA)

While not directly usable in cell formulas, within a VBA macro, GET.CELL could be used like this (Illustrative Example, requires adaptation based on desired type_num):

Sub GetCellInfo()
  Dim cellColor As Integer
  cellColor = Application.WorksheetFunction.GetCell(7, "A1") ' Hypothetical example,  7 might correspond to color; check available type_nums
  MsgBox "Cell A1 color index: " & cellColor 
End Sub

This VBA code snippet attempts to get the color index of cell A1. The exact type_num for color would need to be verified through experimentation or more detailed Excel 4 macro function documentation, which is scarce.

Alternatives to GET.CELL

For obtaining cell information within regular formulas, consider using functions like:

  • CELL: Returns information about a cell but with more limited capabilities than GET.CELL.
  • ADDRESS, ROW, COLUMN, etc.: These functions can retrieve cell location details.
  • Custom VBA functions: If GET.CELL's functionality is crucial, a custom VBA function can encapsulate its use and expose a more user-friendly interface.

Limitations and Considerations

  • GET.CELL is an older Excel 4 macro function, making it less accessible and documented compared to more modern functions.
  • The specific numerical codes for various type_num values may not be easily discoverable.
  • It's typically used within VBA macros, not directly in worksheet formulas.