Loop Macro with isText() function

drwashngtn

New Member
Joined
Jul 13, 2004
Messages
1
Hello,

I'm having quite a diffecult time with creating this macro.

What I'm trying to do is loop through a column of cells to check if each one is text or a number and if it is text then conduct an operation. So far my attempts have failed and my Macro gets an error when it reaches the IsText function. this is my macro so far:

Sub LoopTry()

Range("E667").Select

n = 1
test = 0
For Each c In ActiveCell.CurrentRegion.Cells
If (IsText(c.Value) = True) Then test = 1
If (test = 0) Then Next
Else
n = n + 1
Next
.Range("E667") = n


End Sub


Any help that you could give me would be appreciated.

Thank You,

Seth-Elliot Drori
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hello and welcome to the board,

How about this code?

Code:
Sub CHECK_FOR_NUMBER_OR_TEXT()
For MY_ROWS = 1 To Range("A65536").End(xlUp).Row
If IsNumeric(Range("A" & MY_ROWS).Value) Then
    MY_ENTRY = MsgBox("NUMBER IN CELL A" & MY_ROWS)
Else
    MY_ENTRY = MsgBox("TEXT IN CELL A" & MY_ROWS)
End If
Next MY_ROWS
End Sub

Change the MY_ENTRY line to your code.
 
Upvote 0
the IsText function

Is this a user defined function?

XL doesn't have an IsText function built in (97 anyway)
 
Upvote 0
IsText is a worksheet function. To use it in VBA, prefix with Application e.g.

Sub macro1()
If Application.IsText(Worksheets("Sheet1").Range("A3")) Then
MsgBox "Yes"
Else
MsgBox "No"
End If

End Sub

On the other hand, “IsNumeric” is a VBA function. As noted by SIXTH SENSE, to test for Text use Isnumeric in the negative:

Sub macro1A()
If Not IsNumeric(Worksheets("Sheet1").Range("A3")) Then
MsgBox "Yes"
Else
MsgBox "No"
End If

End Sub

Regards,

Mike
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,892
Members
449,058
Latest member
Guy Boot

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top