+ Reply to Thread
Results 1 to 4 of 4

Message Box Improvements

  1. #1
    Phil Hageman
    Guest

    Message Box Improvements

    This code counts the characters and spaces in a cell. Could the message box
    be modified to also show the sum of characters and spaces, as well as a text
    statement Characters > 255 will not paste?

    Sub CountCharacters()
    Dim StringLength As Integer
    Dim EmptySpaces As Integer
    Dim I As Integer
    Dim CellRef As Variant
    CellRef = Trim(ActiveCell.Value)
    StringLength = Len(ActiveCell.Value)
    For I = 1 To Len(ActiveCell.Value)
    If Mid(CellRef, I, 1) = " " Then EmptySpaces = EmptySpaces + 1
    Next
    MsgBox "Characters: " & StringLength & Chr(10) & "Empty Spaces: " &
    EmptySpaces
    End Sub


  2. #2
    Bob Phillips
    Guest

    Re: Message Box Improvements

    Do you mean

    MsgBox "Characters: " & StringLength & Chr(10) & _
    "Empty Spaces: " & EmptySpaces & Chr(10) & _
    "CharCharacters > 255 will not paste"

    --
    HTH

    Bob Phillips

    "Phil Hageman" <[email protected]> wrote in message
    news:[email protected]...
    > This code counts the characters and spaces in a cell. Could the message

    box
    > be modified to also show the sum of characters and spaces, as well as a

    text
    > statement "Characters > 255 will not paste"?
    >
    > Sub CountCharacters()
    > Dim StringLength As Integer
    > Dim EmptySpaces As Integer
    > Dim I As Integer
    > Dim CellRef As Variant
    > CellRef = Trim(ActiveCell.Value)
    > StringLength = Len(ActiveCell.Value)
    > For I = 1 To Len(ActiveCell.Value)
    > If Mid(CellRef, I, 1) = " " Then EmptySpaces = EmptySpaces + 1
    > Next
    > MsgBox "Characters: " & StringLength & Chr(10) & "Empty Spaces: " &
    > EmptySpaces
    > End Sub
    >




  3. #3
    Phil Hageman
    Guest

    Re: Message Box Improvements

    Hi Bob,

    Getting closer. Need somehting like:

    Characters 215
    Spaces 22
    Total 237

    Text message is good.

    Phil

    "Bob Phillips" wrote:

    > Do you mean
    >
    > MsgBox "Characters: " & StringLength & Chr(10) & _
    > "Empty Spaces: " & EmptySpaces & Chr(10) & _
    > "CharCharacters > 255 will not paste"
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Phil Hageman" <[email protected]> wrote in message
    > news:[email protected]...
    > > This code counts the characters and spaces in a cell. Could the message

    > box
    > > be modified to also show the sum of characters and spaces, as well as a

    > text
    > > statement "Characters > 255 will not paste"?
    > >
    > > Sub CountCharacters()
    > > Dim StringLength As Integer
    > > Dim EmptySpaces As Integer
    > > Dim I As Integer
    > > Dim CellRef As Variant
    > > CellRef = Trim(ActiveCell.Value)
    > > StringLength = Len(ActiveCell.Value)
    > > For I = 1 To Len(ActiveCell.Value)
    > > If Mid(CellRef, I, 1) = " " Then EmptySpaces = EmptySpaces + 1
    > > Next
    > > MsgBox "Characters: " & StringLength & Chr(10) & "Empty Spaces: " &
    > > EmptySpaces
    > > End Sub
    > >

    >
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: Message Box Improvements

    MsgBox "Characters: " & StringLength & vbnewline & _
    "Spaces: " & EmptySpaces & vbNewLine & _
    "Total " & StringLength + EmptySpaces

    --
    HTH

    Bob Phillips

    "Phil Hageman" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Bob,
    >
    > Getting closer. Need somehting like:
    >
    > Characters 215
    > Spaces 22
    > Total 237
    >
    > Text message is good.
    >
    > Phil
    >
    > "Bob Phillips" wrote:
    >
    > > Do you mean
    > >
    > > MsgBox "Characters: " & StringLength & Chr(10) & _
    > > "Empty Spaces: " & EmptySpaces & Chr(10) & _
    > > "CharCharacters > 255 will not paste"
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "Phil Hageman" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > This code counts the characters and spaces in a cell. Could the

    message
    > > box
    > > > be modified to also show the sum of characters and spaces, as well as

    a
    > > text
    > > > statement "Characters > 255 will not paste"?
    > > >
    > > > Sub CountCharacters()
    > > > Dim StringLength As Integer
    > > > Dim EmptySpaces As Integer
    > > > Dim I As Integer
    > > > Dim CellRef As Variant
    > > > CellRef = Trim(ActiveCell.Value)
    > > > StringLength = Len(ActiveCell.Value)
    > > > For I = 1 To Len(ActiveCell.Value)
    > > > If Mid(CellRef, I, 1) = " " Then EmptySpaces = EmptySpaces + 1
    > > > Next
    > > > MsgBox "Characters: " & StringLength & Chr(10) & "Empty Spaces: " &
    > > > EmptySpaces
    > > > End Sub
    > > >

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1