• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to print only non numerical characters in msgbox using macro

ThrottleWorks

Excel Ninja
I have a macro, code is pasted below.

The macro is taking a string from the input box & then printing each letter in the msgbox.


My problem is I do not want to print numbers.


For example if the user has inputted “Sachin83abc”


I want to print s a c h I n a b c


Can anyone help me in this please


Sub Test()


Dim strName As String

Dim MyLen As Integer


strName = InputBox(Prompt:="Please enter your name", _

Title:="ENTER YOUR NAME", Default:="Your Name here")

Worksheets("Set 2").Range("d16").Value = strName


If Len(Worksheets("Set 2").Range("d16").Value) < 5 Then

MsgBox "Invalid word !"

Exit Sub

Else


Dim strArray() As String

Dim strText As String

Dim lLoop As Long, lCount As Long


strText = Worksheets("Set 2").Range("d16").Value

lCount = Len(strText)

ReDim strArray(lCount - 1)


For lLoop = 0 To lCount - 1

strArray(lLoop) = Mid(strText, lLoop + 1, 1)

MsgBox strArray(lLoop)

Next lLoop


End If

End Sub
 
Hi Sachin,


Just change:

Code:
MsgBox strArray(lLoop)

to

If Not IsNumeric(strArray(lLoop)) Then MsgBox strArray(lLoop)
 
Back
Top