![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 25
|
I'm opening a file I have no control over and cell D24 reads as follows :
Cash Left: ###,### I want to only read in the # into an integer, not a string. How can I do this? Thanks... |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Not sure what you mean, but would sticking:
=INT(D24) in a cell be any good to you? |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 25
|
Cell D24 = "Cash Left: 392,000"
dim money as integer I want an integer variable (money) equal to 392,000. I can read the the cells value as a string, but a) I do not want the "Cash Left:" part and b) I want 392,000 as an integer, not a string. |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Try this, changing the value of sMoney to whatever cell you want.
I'm assuming that you are always going to have colon in the sentence before the number. HTH |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
Are you reading the cell into a variable, or do you want to change the cell on the worksheet? If the latter, try: Sub test() Dim cell As Range For Each cell In Selection cell = WorksheetFunction.Substitute(cell, "Cash Left:", "") + 0 Next cell End Sub Note also that you cannot read your example into an Integer variable. Change it to Long or Double. myVari = WorksheetFunction.Substitute(cell, "Cash Left:", "") + 0 If you have Excel 2000 or XP, I believe there is a Replace function that can be used instead of worksheetfunction.substitute HTH, Jay EDIT: Scratch this answer. Mark's is nicer. [ This Message was edited by: Jay Petrulis on 2002-04-22 13:26 ] |
|
|
|
|
|
#6 |
|
New Member
Join Date: Apr 2002
Posts: 25
|
Thanks! Works like a charm....
|
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Oh for God's sakes Jay! You're just far too nice to me.
I liked your solution. I wouldn't even have considered that, because I didn't know it existed. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|