Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default number/text problem

Worsheet is composed of numbers in string (txt) format.

is there a way to sum columns etc without destroying the txt format?

also

Is there a sum function in vb? I can't find one.

like c=sum("a1:a9") where c is an integer or long

Alternately. Is there a way to turn of calculating in only particular cells?

thanks
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default number/text problem

In VB in general if you want to add up a bunch of numbers you have to loop
through them all. But in VBA/Excel (which is what I suppose you mean in this
case) you can either do it that way, or you can imitate the Worksheet
function by saying Application.WorksheetFunctions.Sum(RangeObject), where
RangeObject is some Range reference, for instance
ActiveSheet.Range("A9:D43").

As for summing up text values that look like numbers, you're asking about
doing it with an Excel formula not a VBA program, right? And I suppose
you've already tried just plain SUM()? If that doesn't work, the way I'd do
it is set up a range of formulae =VALUE(RC[-11]) (I use R1C1 notation when
possible but you can do it in A1 too of course) and sum those. VALUE, if I
remember correctly, converts a text string to the number it represents.

--- "John" wrote:
Worsheet is composed of numbers in string (txt) format. is there a way to sum
columns etc without destroying the txt format?

also, Is there a sum function in vb? I can't find one. like c=sum("a1:a9") where c
is an integer or long. Alternately. Is there a way to turn of calculating in only
particular cells?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default number/text problem

Hi John,

Without converting the individual values of the text range to numeric with
the worksheet VALUE function (or Val function in VBA) , I don't think you can
sum text values.

On the other question

c = WorksheetFunction.Sum(Range("A1:A9"))

Many of the worksheet functions are available in VBA with WorksheetFunction.
When you type it in, after placing the dot at the end of WorksheetFunction
you should get a dropdown listing them.


--
Regards,

OssieMac


"John" wrote:

Worsheet is composed of numbers in string (txt) format.

is there a way to sum columns etc without destroying the txt format?

also

Is there a sum function in vb? I can't find one.

like c=sum("a1:a9") where c is an integer or long

Alternately. Is there a way to turn of calculating in only particular cells?

thanks
John

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
Converting Number to Month in Text Problem RyanH Excel Worksheet Functions 5 March 30th 10 08:06 AM
Problem With Text & number format zyus Excel Discussion (Misc queries) 1 March 22nd 10 09:22 AM
The number in this cell is formatted as text or preceded by an apostrophe" problem in Excel [email protected] Excel Discussion (Misc queries) 2 July 13th 06 01:55 PM
number to text problem GottaRun Excel Discussion (Misc queries) 2 February 19th 06 06:30 AM
countif (problem: text, number) chrismania[_9_] Excel Programming 2 November 5th 03 01:04 PM


All times are GMT +1. The time now is 10:24 AM.

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

About Us

"It's about Microsoft Excel"