Sub WorksheetChange()
'declare a variable
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Foundation Budget Template")
'calculate if a cell contains text, using the ISNUMBER function, and then return a specified value
If Application.WorksheetFunction.IsNumber(ws.Range("A1:A100")) = False Then
ws.Range("C1:C100") = "Contains Text"
Else
ws.Range("C1:C100") = "No Text"
End If
End Sub
I keep getting a type mismatch 13 error. I am not sure where my types fail but I want to find out. This vba code is for Scanning column A and if Column A is a number then post "contains text" otherwise if A is not a number post "no text" in column C.
Sub WorksheetChange()
'declare a variable
Dim ws As Worksheet
Dim row As Long
Set ws = ThisWorkbook.Worksheets(1)
'calculate if a cell contains text, using the ISNUMBER function, and then return a specified value
For row = 1 To 100
If Application.WorksheetFunction.IsNumber(ws.Cells(row, 1)) = False Then
ws.Cells(row, 3) = "Contains Text"
Else
ws.Cells(row, 3) = "No Text"
End If
Next row
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.