If a cell contains text
Macro Title:
|
Worksheet Variable:
|
Worksheet Name:
|
Test Cell Reference:
enter the cell that you want to test |
Output Cell:
|
Value if test is True:
enter the value that you want returned if a cell contains text |
Value if test is False:
enter the value that you want returned if a cell does not contain text |
First Comment:
' |
Second Comment:
' |
Sub If_a_cell_contains_text_with_the_ISNUMBER_function()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'calculate if a cell contains text, using the ISNUMBER function, and then return a specified value
If Application.WorksheetFunction.IsNumber(ws.Range("B5")) = False Then
ws.Range("C5") = "Contains Text"
Else
ws.Range("C5") = "No Text"
End If
End Sub
Sub If_a_cell_contains_text_with_the_ISNUMBER_function()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'calculate if a cell contains text, using the ISNUMBER function, and then return a specified value
If Application.WorksheetFunction.IsNumber(ws.Range("B5")) = False Then
If Application.WorksheetFunction.IsNumber(ws.Range("B5")) = False Then
ws.Range("C5") = "Contains Text"
Else
ws.Range("C5") = "No Text"
End If
End Sub