ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change from message box to result in cell (https://www.excelbanter.com/excel-programming/384311-change-message-box-result-cell.html)

DB

change from message box to result in cell
 
I'm currently running this macro...
**********
Sub Sumcharacters()
Dim i As Long, s As String
Dim lsum As Long
For i = 1 To Len(ActiveCell)
s = Mid(ActiveCell, i, 1)
If IsNumeric(s) Then
lsum = lsum + CLng(s)
End If
Next
MsgBox lsum
End Sub
**********
Instead of the sum showing up in a message box, I'd like the sum to show up
in the next cell over. Can someone help me out on how to do that. I can't
seem to get it to work smoothly.

Thanks

L. Howard Kittle

change from message box to result in cell
 
Try this

Sub Sumcharacters()
Dim i As Long, s As String
Dim lsum As Long
For i = 1 To Len(ActiveCell)
s = Mid(ActiveCell, i, 1)
If IsNumeric(s) Then
lsum = lsum + CLng(s)
End If
Next
ActiveCell.Offset(0, 1).Value = lsum
End Sub

HTH
Regards,
Howard

"DB" wrote in message
...
I'm currently running this macro...
**********
Sub Sumcharacters()
Dim i As Long, s As String
Dim lsum As Long
For i = 1 To Len(ActiveCell)
s = Mid(ActiveCell, i, 1)
If IsNumeric(s) Then
lsum = lsum + CLng(s)
End If
Next
MsgBox lsum
End Sub
**********
Instead of the sum showing up in a message box, I'd like the sum to show
up
in the next cell over. Can someone help me out on how to do that. I can't
seem to get it to work smoothly.

Thanks




DB

change from message box to result in cell
 
perfect, thank you for the help

"L. Howard Kittle" wrote:

Try this

Sub Sumcharacters()
Dim i As Long, s As String
Dim lsum As Long
For i = 1 To Len(ActiveCell)
s = Mid(ActiveCell, i, 1)
If IsNumeric(s) Then
lsum = lsum + CLng(s)
End If
Next
ActiveCell.Offset(0, 1).Value = lsum
End Sub

HTH
Regards,
Howard

"DB" wrote in message
...
I'm currently running this macro...
**********
Sub Sumcharacters()
Dim i As Long, s As String
Dim lsum As Long
For i = 1 To Len(ActiveCell)
s = Mid(ActiveCell, i, 1)
If IsNumeric(s) Then
lsum = lsum + CLng(s)
End If
Next
MsgBox lsum
End Sub
**********
Instead of the sum showing up in a message box, I'd like the sum to show
up
in the next cell over. Can someone help me out on how to do that. I can't
seem to get it to work smoothly.

Thanks





Dave Peterson

change from message box to result in cell
 
You have another response at your original post.

DB wrote:

I'm currently running this macro...
**********
Sub Sumcharacters()
Dim i As Long, s As String
Dim lsum As Long
For i = 1 To Len(ActiveCell)
s = Mid(ActiveCell, i, 1)
If IsNumeric(s) Then
lsum = lsum + CLng(s)
End If
Next
MsgBox lsum
End Sub
**********
Instead of the sum showing up in a message box, I'd like the sum to show up
in the next cell over. Can someone help me out on how to do that. I can't
seem to get it to work smoothly.

Thanks


--

Dave Peterson


All times are GMT +1. The time now is 11:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com