Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default How do i stop numbers stringing together ? AB

I am using Visual Basic to add numbers in a macro in an Excel spreadsheet.
Something has now changed to where the resulting value of the numbers to be
added is a string of those numbers instead of the sum.
This is the format of the formula I am using:
total.value = a.value + b.value + c.value
If a = 1, b = 2, c = 3, then total.value returns 123, not 6.
This is the case in the file I'm currently working on as well as any new
file which uses this same type of formula. I've tried searching for any
settings that might have caused it to produce this result and used VB and
Excel Help without any success so far. Please help. Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default How do i stop numbers stringing together ? AB

Something like:

Sub andy1()
Dim a As Range, b As Range, c As Range, total As Range
Set a = Cells(1, 1)
Set b = Cells(2, 1)
Set c = Cells(3, 1)
Set total = Cells(4, 1)
total.Value = a.Value + b.Value + c.Value
End Sub

will produce 123 if the worksheet cells contain text. Make sure they
contain numbers.
--
Gary's Student


"Andy Bleese" wrote:

I am using Visual Basic to add numbers in a macro in an Excel spreadsheet.
Something has now changed to where the resulting value of the numbers to be
added is a string of those numbers instead of the sum.
This is the format of the formula I am using:
total.value = a.value + b.value + c.value
If a = 1, b = 2, c = 3, then total.value returns 123, not 6.
This is the case in the file I'm currently working on as well as any new
file which uses this same type of formula. I've tried searching for any
settings that might have caused it to produce this result and used VB and
Excel Help without any success so far. Please help. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default How do i stop numbers stringing together ? AB

Sub andy1()
Dim a As single, b As single, c As single, total As single
a = Cells(1, 1).value
b = Cells(2, 1).value
c = Cells(3, 1).value
total = a.+ b + c
Cells(4, 1).value = total
End Sub

I used single in case there were decimals; if not, you could use As
Integer.
I didn't try it, but it ought to work.
Kathy




Gary''s Student wrote:
Something like:

Sub andy1()
Dim a As Range, b As Range, c As Range, total As Range
Set a = Cells(1, 1)
Set b = Cells(2, 1)
Set c = Cells(3, 1)
Set total = Cells(4, 1)
total.Value = a.Value + b.Value + c.Value
End Sub

will produce 123 if the worksheet cells contain text. Make sure they
contain numbers.
--
Gary's Student


"Andy Bleese" wrote:

I am using Visual Basic to add numbers in a macro in an Excel spreadsheet.
Something has now changed to where the resulting value of the numbers to be
added is a string of those numbers instead of the sum.
This is the format of the formula I am using:
total.value = a.value + b.value + c.value
If a = 1, b = 2, c = 3, then total.value returns 123, not 6.
This is the case in the file I'm currently working on as well as any new
file which uses this same type of formula. I've tried searching for any
settings that might have caused it to produce this result and used VB and
Excel Help without any success so far. Please help. Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default How do i stop numbers stringing together ? AB

Works cool, but you need to eliminate the dot after the a in the line
to read:
total = a + b + c
instead of:
total = a.+ b + c

Vaya con Dios,
Chuck, CABGx3





"KathyC" wrote:

Sub andy1()
Dim a As single, b As single, c As single, total As single
a = Cells(1, 1).value
b = Cells(2, 1).value
c = Cells(3, 1).value
total = a.+ b + c
Cells(4, 1).value = total
End Sub

I used single in case there were decimals; if not, you could use As
Integer.
I didn't try it, but it ought to work.
Kathy




Gary''s Student wrote:
Something like:

Sub andy1()
Dim a As Range, b As Range, c As Range, total As Range
Set a = Cells(1, 1)
Set b = Cells(2, 1)
Set c = Cells(3, 1)
Set total = Cells(4, 1)
total.Value = a.Value + b.Value + c.Value
End Sub

will produce 123 if the worksheet cells contain text. Make sure they
contain numbers.
--
Gary's Student


"Andy Bleese" wrote:

I am using Visual Basic to add numbers in a macro in an Excel spreadsheet.
Something has now changed to where the resulting value of the numbers to be
added is a string of those numbers instead of the sum.
This is the format of the formula I am using:
total.value = a.value + b.value + c.value
If a = 1, b = 2, c = 3, then total.value returns 123, not 6.
This is the case in the file I'm currently working on as well as any new
file which uses this same type of formula. I've tried searching for any
settings that might have caused it to produce this result and used VB and
Excel Help without any success so far. Please help. Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop numbers from rounding in Excel? Josette_N Excel Discussion (Misc queries) 10 January 27th 06 03:19 PM
the end of long numbers turn to 0s how do i stop that? Shawna New Users to Excel 2 November 21st 05 07:19 PM
Stop text from stringing into next field when empty NothingButRomance Excel Worksheet Functions 7 May 17th 05 02:22 AM
Stop text from stringing into next field when empty NothingButRomance Excel Worksheet Functions 2 May 15th 05 05:32 PM
How do I stop excel from changing single numbers like 1 into a de. Jendayii Excel Discussion (Misc queries) 1 January 5th 05 10:03 PM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"