Excel Text to number conversion

First some background

So I got bored and decided I wanted to look for sites that graphically tracked the change in a stocks EPS over time. I really want to track atleast 5 years worth of data so I have enough data points. www.earnings.com gives me the necessary data however when i cut and paste the earnings history into excel for some reason the earnings figures are pasted as text or something that doesnt allow me to treat them as I otherwise a number.

For example

A1= $0.27
A2= $0.35

I want to add A1 and A2, however when i do it simply displays it as #VALUE

I have tryed using text to column, I have tryed multiplying the selected cells by 1, and i have even tryed the following macro.

  Sub Enter_Values()
      For Each xCell In Selection
          xCell.Value = xCell.Value
      Next xCell
  End Sub

How do I convert these so i can run operations on the data?! Thanks.

 

After playing around with it some more it appears that what is causing the problem is a space at the end of the string. For some reason when i use the TRIM function it still does not work correctly. Again any help would greatly be appreciated. I have ran into this problem many times and I absolutely hate having go through my hand and retype it.

"Oh the ladies ever tell you that you look like a fucking optical illusion" - Frank Slaughtery 25th Hour.
 
Best Response

http://www.mvps.org/dmcritchie/excel/join.htm#trimall

Used this code

Sub RemoveAllSpaces() 'David McRitchie 2000-10-24 Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Selection.SpecialCells(xlConstants).Replace What:=Chr(160), _ Replacement:="", _ LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=True Selection.SpecialCells(xlConstants).Replace What:=Chr(32), _ Replacement:="", _ LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=True Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub

Pretty helpfull feature, if you need to pull large amounts of data from tables on web sites and when you cut and paste it comes out as HTML and not numbers this will fix the problem. This will save me hours.

Now i just cant figure out how to save the macro for general use. since it will be something i do pretty common.

"Oh the ladies ever tell you that you look like a fucking optical illusion" - Frank Slaughtery 25th Hour.
 

Sub ConvertToNum() Dim bCell as Range, TheNum as String For Each bCell in Selection TheNum = Replace(Range(bCell).value, " ", "") TheNum = Replace(TheNum,"$", "") Range(bCell).value = cdbl(TheNum) Next bCell End Sub

Assign an easy short-cut key to your macro, makes it alot easier. That should work on every cell in the range you select.

 

Correction:

Sub ConvertToNum() Dim bCell As Range, TheNum As String For Each bCell In Selection TheNum = Replace(bCell, " ", "") TheNum = Replace(TheNum, "$", "") bCell.Value = CDbl(TheNum) bCell.NumberFormat = "0.00" Next bCell End Sub

elan:
Sub ConvertToNum() Dim bCell as Range, TheNum as String For Each bCell in Selection TheNum = Replace(Range(bCell).value, " ", "") TheNum = Replace(TheNum,"$", "") Range(bCell).value = cdbl(TheNum) Next bCell End Sub

Assign an easy short-cut key to your macro, makes it alot easier. That should work on every cell in the range you select.

 

Elan- I cant figure out how to assign a short cut key to the macro. Im still very new to VBA and macros but as i tend to need more features i learn new things.

Stern- I was drinking when i did this.... (excel)models & bottles BABY! Ohhhh yeah.

"Oh the ladies ever tell you that you look like a fucking optical illusion" - Frank Slaughtery 25th Hour.
 

ALT+T+M+M or Alt+F8 or goto TOOLS in the menu, then MACRO then MACROS

Once the Macro dialog window comes up, select the macro you want to assign a shortcut key to and then click the OPTIONS button or hit ALT+O. This will let you assign a shortcut key to the macro. VERY VERY helpful.

CTRL+ whatever key you assign

trade4size:
Elan- I cant figure out how to assign a short cut key to the macro. Im still very new to VBA and macros but as i tend to need more features i learn new things.

Stern- I was drinking when i did this.... (excel)models & bottles BABY! Ohhhh yeah.

 

Quis nihil quas perspiciatis cum esse et iste. Ullam dolores maxime inventore nemo nulla rem eos. Facere dolor atque suscipit architecto porro dignissimos placeat. Ut explicabo ex enim dolorem similique. Qui magni et dolores saepe sunt sit laudantium.

Qui possimus iste ratione facilis architecto quod et. Molestias qui cumque et est rem sed. Et quia accusamus voluptatum quia hic.

Autem dolores autem veritatis. Quas illo minus quasi qui.

"Oh the ladies ever tell you that you look like a fucking optical illusion" - Frank Slaughtery 25th Hour.

Career Advancement Opportunities

April 2024 Investment Banking

  • Jefferies & Company 02 99.4%
  • Goldman Sachs 19 98.8%
  • Harris Williams & Co. New 98.3%
  • Lazard Freres 02 97.7%
  • JPMorgan Chase 03 97.1%

Overall Employee Satisfaction

April 2024 Investment Banking

  • Harris Williams & Co. 18 99.4%
  • JPMorgan Chase 10 98.8%
  • Lazard Freres 05 98.3%
  • Morgan Stanley 07 97.7%
  • William Blair 03 97.1%

Professional Growth Opportunities

April 2024 Investment Banking

  • Lazard Freres 01 99.4%
  • Jefferies & Company 02 98.8%
  • Goldman Sachs 17 98.3%
  • Moelis & Company 07 97.7%
  • JPMorgan Chase 05 97.1%

Total Avg Compensation

April 2024 Investment Banking

  • Director/MD (5) $648
  • Vice President (19) $385
  • Associates (87) $260
  • 3rd+ Year Analyst (14) $181
  • Intern/Summer Associate (33) $170
  • 2nd Year Analyst (66) $168
  • 1st Year Analyst (205) $159
  • Intern/Summer Analyst (146) $101
notes
16 IB Interviews Notes

“... there’s no excuse to not take advantage of the resources out there available to you. Best value for your $ are the...”

Leaderboard

1
redever's picture
redever
99.2
2
Secyh62's picture
Secyh62
99.0
3
BankonBanking's picture
BankonBanking
99.0
4
Betsy Massar's picture
Betsy Massar
99.0
5
CompBanker's picture
CompBanker
98.9
6
GameTheory's picture
GameTheory
98.9
7
kanon's picture
kanon
98.9
8
dosk17's picture
dosk17
98.9
9
Linda Abraham's picture
Linda Abraham
98.8
10
DrApeman's picture
DrApeman
98.8
success
From 10 rejections to 1 dream investment banking internship

“... I believe it was the single biggest reason why I ended up with an offer...”