473,414 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

List of numbers to formula

25
I am trying to create a small VB program that will take a list of numbers in excel and put it into a single cell.

Example:
Turn this:
-547119.67
-19700.00
-2170.50
115.00
10504.56
186131.59
-75669.81
17180.82
-44261.34

Into this:

=-547119.67-19700-2170.50+115+10504.56+186131.59-75669.81+17180.82-44261.34

I need have it so the cells reads out as a single number, not text. Also, I need to do this in VB because I will be surrounding it with other parameters to select which numbers in the list to use.

Thanks for any Help!!
Feb 12 '08 #1
5 1088
kadghar
1,295 Expert 1GB
I am trying to create a small VB program that will take a list of numbers in excel and put it into a single cell.

Thanks for any Help!!
use FOR - NEXT or DO-LOOP and CELLS... may be WORKSHEETS

this might give you a general idea:

Expand|Select|Wrap|Line Numbers
  1. sub something()
  2. dim i as long
  3. dim b as double
  4. for i = 1 to 10
  5.     b= b + cells(i,1)
  6. next
  7. cells(1,2)=b
  8. end sub
will sum A1:A10 and write the result in B1

well
HTH
Feb 12 '08 #2
kadghar
1,295 Expert 1GB
Oh in case i misunderstood the question

Expand|Select|Wrap|Line Numbers
  1. sub something()
  2. dim i as long
  3. dim b as string
  4. b = "="
  5. for i = 1 to 10
  6.     if mid(cells(i,1),1,1)="-" then
  7.         b= b  & cells(i,1)
  8.     else
  9.         b= b  & "+" & cells(i,1)
  10.     end if
  11. next
  12. cells(1,2)=b
  13. end sub
this might be of help as well
Feb 12 '08 #3
if1467
25
use FOR - NEXT or DO-LOOP and CELLS... may be WORKSHEETS

will sum A1:A10 and write the result in B1

well
HTH
That is a good start, but in addtion to this I need the out put cell to have all the numbers in the formula, not just the sum.

Any ideas?
Feb 12 '08 #4
if1467
25
Oh in case i misunderstood the question

Expand|Select|Wrap|Line Numbers
  1. sub something()
  2. dim i as long
  3. dim b as string
  4. b = "="
  5. for i = 1 to 10
  6.     if mid(cells(i,1),1,1)="-" then
  7.         b= b  & cells(i,1)
  8.     else
  9.         b= b  & "+" & cells(i,1)
  10.     end if
  11. next
  12. cells(1,2)=b
  13. end sub
this might be of help as well
That's it!!!

Thanks so much!!!
Feb 12 '08 #5
kadghar
1,295 Expert 1GB
That is a good start, but in addtion to this I need the out put cell to have all the numbers in the formula, not just the sum.

Any ideas?
yes, sorry, check post #3
Feb 12 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: dleecurt | last post by:
Hello, I have a small problem, I am trying to write a program that will calculate the Fibonacci number series, and I have the code complete with one problem. I used a long in to store the numbers,...
22
by: Allen Thompson | last post by:
Is there a script that will round off a number to a certain number of decimal places? -Allen Thompson
24
by: Stavros Christoforou | last post by:
Hello everyone, I was wondering if someone could help me with an issue I have in C++. I want to select random points within the volume of a sphere. I know how to get random numbers using srand()...
23
by: MConly | last post by:
Can you tell me what happens inside CPU when I rand() ? Where can I find the true rand function implemented ? I have heard that rand() in C/C++ is n't a good one but why it isn't a good one, are...
19
by: Eduardo Bezerra | last post by:
Hi, I'm looking for an efficient way to create the oposite of a list of numbers. For example, suppose I have this list of numbers: 100 200 300
3
by: JoelPJustice | last post by:
I am working through a VBA book by myself to help and try and improve my skills. However, the book does not give you solutions to certain problems. I have worked through this problem up until bullet...
12
by: vj | last post by:
Hi! I have a piece of code (shown below) involving complex numbers. The code is not running and giving error ("Invalid floating point operation" and "SQRT:Domain error"). I would be very...
39
by: Frederick Gotham | last post by:
I have a general idea about how negative number systems work, but I'd appreciate some clarification if anyone would be willing to help me. Let's assume we're working with an 8-Bit signed integer,...
1
by: Reggie | last post by:
Hi and TIA! I'm exporting a dataset/datgrid to excel but some text fields get converted to numbers in excel and I loose leading zero's. I've tried several methods with no success. If anyone has...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.