Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Malriem,
Thanks for your reply - this works exactly as needed. Can the code be modified to sum the string length and number of characters and add that sum in the message block? Thanks, Phil "Malriem" wrote: It would be close to the same as the last except: Dim StrinLen As Integer Dim EmptySpaces As Integer Dim I As Integer CellRef = Trim(ActiveCell.Value) StrinLen = Len(ActiveCell.Value) For I = 1 To Len(ActiveCell.Value) If Mid(CellRef, I, 1) = " " Then EmptySpaces = EmptySpaces + 1 Next MsgBox "String Lengh: " & StrinLen & Chr(10) & "Empty Spaces: " & EmptySpaces "Phil Hageman" wrote: Folks, What I need is a toolbar button with a macro attached such that were ever I am in any workbook, by clicking the button, I get a message box with the number of characters and spaces in the current cell. Aren't functions typically used in a particular cell? Thanks, Phil "cscorp" wrote: Function CountSpaces(CellRef) Dim StrinLen As Integer Dim EmptySpaces As Integer Dim I As Integer CellRef = Trim(CellRef) StrinLen = Len(CellRef) For I = 1 To Len(CellRef) If Mid(CellRef, I, 1) = " " Then EmptySpaces = EmptySpaces + 1 Next CountSpaces = "String Lengh: " & StrinLen & ", Empty Spaces: " & Chr(10) _ & EmptySpaces End Function -- cscorp ------------------------------------------------------------------------ cscorp's Profile: http://www.excelforum.com/member.php...o&userid=24015 View this thread: http://www.excelforum.com/showthread...hreadid=376338 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Counting characters within a cell | Excel Worksheet Functions | |||
Counting characters in a cell | Excel Discussion (Misc queries) | |||
counting characters in a cell | Excel Discussion (Misc queries) | |||
Counting Characters in a cell | Excel Programming | |||
Counting Characters in a Cell | Excel Worksheet Functions |