0

I have an Excel spreadsheet with some 4000 instances of data entered in a cell as (for example) =234+3455+456+876. [The data are stock market related.] It turns out I only need the first two data elements. Each datum can be anywhere from 1 to 4 or 5 characters long.

I'm VBA illiterate, but was wondering if someone could point me toward a macro or global command that would truncate the string after the last digit of the first two data elements. So, the above string would end up as =234+3455. Maybe an "if, then" function of some sort? How would I apply same to the entire spreadsheet?

At this point, I could probably have just manually deleted the 4000 cells, but now it has become a challenge!! I also realize I really need to learn VBA!

Any help would be most appreciated.

pnuts
  • 58,317
  • 11
  • 87
  • 139
James
  • 1
  • 1

2 Answers2

0

How about a formula? No need for VBA

=LEFT(A1;FIND("+";A1;FIND("+";A1)+1)-1)

Assuming data you want to truncate is in cell A1

rois
  • 131
  • 1
  • 3
  • Thanks for the help! I will work with your solution to familiarize myself with the syntax. I actually solved the problem by using the "text to columns" function and directing the function to consider "+" signs as delimiters. This broke the four number entries into four columns and then I simply deleted the two unwanted columns and summed the two columns I wanted. – James Sep 16 '13 at 14:59
0

One solution to this problem is to use the "Text to Columns" function and direct the function to consider "+" signs as delimiters. This broke the four numbers in the cell into four numbers, each in its own cell across four columns. I could then delete the last two columns and then sum the first two columns.

James
  • 1
  • 1