I am a supporter of St. Joseph's hospice. If you find this site useful or if it helped you, consider a small donation to St. Joseph's, please.
You can retrieve interesting information about worksheet cells by using the Excel4 macro function GET.CELL. Define the name HasFormula with the value
=GET.CELL(48,INDIRECT("RC[-1]",FALSE))
for example. If you now insert =HasFormula next right to a cell, you will be shown whether the cell has a formula (True) or not (False).
Another example for GET.CELL you can find here.
An overview over some arguments for GET.CELL:
|
Proposed Name |
Arg # |
What =GET.CELL(Arg #,INDIRECT("RC[-1]",)) will return |
|
AbsReference |
1 |
Absolute style reference like [Book1.xls]Sheet1!$A$1 |
|
ShowValue |
5 |
Cell value |
|
ShowFormula |
6 |
Cell formula |
|
NumFormat |
7 |
Number format of cell |
|
IsLocked |
14 |
True if cell is locked |
|
IsHidden |
15 |
True if cell is hidden |
|
ShowWidth |
16 |
Cell width. If array-entered into two cells of a row, second value is true if width is standard |
|
ShowHeight |
17 |
Cell height |
|
WorkbookName |
32 |
Workbook name like [Book1.xls]Sheet1 or Book1.xls if workbook and single sheet have identical names |
|
ShowFormulaWOT |
41 |
Cell formula without translation into language of workspace |
|
HasNote |
46 |
True if cell has a text note |
|
HasFormula |
48 |
True if cell contains a formula |
|
IsArray |
49 |
True if cell is part of an array formula |
|
IsStringConst |
52 |
Text alignment char ' if cell is a string constant, empty string if not |
|
AsText |
53 |
Cell displayed as text with numbers formatted and symbols included |
|
WorksheetName |
62 |
Worksheet name like [Book1.xls]Sheet1 |
|
WorkbookName |
66 |
Workbook name like Book1.xls |
If you want to achieve similar results with VBA use this UDF:
Function GetCell(r As Range, s As String) As Variant
Application.Volatile
Select Case s
Case "AbsReference", "1"
'Absolute style reference like [Book1.xls]Sheet1!$A$1
If Application.Caller.Parent.Parent.Name = r.Worksheet.Parent.Name And _
Application.Caller.Parent.Name = r.Worksheet.Name Then
GetCell = r.Address
Else
If InStr(r.Worksheet.Parent.Name & r.Worksheet.Name, " ") > 0 Then
GetCell = "'[" & r.Worksheet.Parent.Name & "]" & r.Worksheet.Name & "'!" & r.Address
Else
GetCell = "[" & r.Worksheet.Parent.Name & "]" & r.Worksheet.Name & "!" & r.Address
End If
End If
Case "ShowValue", "5"
'Cell value
GetCell = r.Value
Case "ShowFormula", "6"
'Cell formula
GetCell = r.FormulaLocal
Case "NumFormat", "7"
'Number format of cell
GetCell = r.NumberFormatLocal
Case "IsLocked", "14"
'True if cell is locked
GetCell = r.Locked
Case "IsHidden", "15"
'True if cell formula is hidden
GetCell = r.FormulaHidden
Case "ShowWidth", "16"
'Cell width. If array-entered into two cells of a row, second value is true if width is standard
GetCell = r.ColumnWidth 'Not width!
Case "ShowHeight", "17"
'Cell height
GetCell = r.RowHeight
Case "WorkbooksheetName", "32"
'Workbook name like [Book1.xls]Sheet1 or Book1.xls if workbook and single sheet have
'identical names
If r.Worksheet.Parent.Name = r.Worksheet.Name & ".xls" And _
Application.Worksheets.Count = 1 Then
GetCell = r.Worksheet.Parent.Name
Else
GetCell = "[" & r.Worksheet.Parent.Name & "]" & r.Worksheet.Name
End If
Case "ShowFormulaWOT", "41"
'Cell formula without translation into language of workspace
GetCell = r.Formula
Case "HasNote", "46"
'True if cell has a text note
GetCell = Len(r.NoteText) > 0
Case "HasFormula", "48"
'True if cell contains a formula
GetCell = r.HasFormula
Case "IsArray", "49"
'True if cell is part of an array formula
GetCell = r.HasArray
Case "IsStringConst", "52"
'Text alignment char "'" if cell is a string constant, empty string "" if not
GetCell = r.PrefixCharacter
Case "AsText", "53"
'Cell displayed as text with numbers formatted and symbols included
GetCell = Format(r.Value, r.NumberFormatLocal)
Case "WorksheetName", "62"
'Worksheet name like [Book1.xls]Sheet1
GetCell = "[" & r.Worksheet.Parent.Name & "]" & r.Worksheet.Name
Case "WorkbookName", "66"
'Workbook name like Book1.xls
GetCell = r.Worksheet.Parent.Name
Case Else
GetCell = CVErr(xlErrValue)
End Select
End Function
[Sulprobil] [Get it done] [Organisation] [IT] [Controlling] [HR] [Family] [Contact] [Disclaimer]