Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default how do i convert a number stored as text to a numb in a vba loop

hello,

i have a question regarding excel giving the error that the number is stored
as text.

can i convert these cells using a for loop until the last row? i tried
multiplying the cell value by 1 in a for loop but this this did not seem to
work. i still get the green triangle next the cell indicating number stored
as text.

any help is appreciated.

bobm
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default how do i convert a number stored as text to a numb in a vba loop

As you go through the for loop, change the cell's format to General. It may
be stuck as text.
--
Gary's Student


"bobm" wrote:

hello,

i have a question regarding excel giving the error that the number is stored
as text.

can i convert these cells using a for loop until the last row? i tried
multiplying the cell value by 1 in a for loop but this this did not seem to
work. i still get the green triangle next the cell indicating number stored
as text.

any help is appreciated.

bobm

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do i convert a number stored as text to a numb in a vba loop


Hi bobm,

You can convert data types using VBA; there are a number of functions
to accomplish what you want depending on what type of number you wish
to convert the text string form of the 'number' into. To convert it to
an Integer data type, this could work for you:


Code:
--------------------
Dim myVal as Integer
myVal = *CInt*(ActiveCell.Value)
--------------------

Refer to your Visual Basic Help topic "Type Conversion Functions" for
details on the different type conversion functions...

Hope this helps,
theDude


--
theDude
------------------------------------------------------------------------
theDude's Profile: http://www.excelforum.com/member.php...o&userid=16550
View this thread: http://www.excelforum.com/showthread...hreadid=380591

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default how do i convert a number stored as text to a numb in a vba loop

Another option.

Select an empty cell
copy it
select your range to fix
edit|paste special|Check Add

If you need a macro, record it when you do it once. It might be faster than
looping.

Kind of like this:

Option Explicit
Sub testme01()

Dim myHelperCell As Range
Dim myRng As Range

Set myRng = Selection 'or whatever range you want

With ActiveSheet
Set myHelperCell = .Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 1)
End With

With myRng
.NumberFormat = "General"
myHelperCell.Copy
.PasteSpecial Operation:=xlAdd
End With
End Sub


bobm wrote:

hello,

i have a question regarding excel giving the error that the number is stored
as text.

can i convert these cells using a for loop until the last row? i tried
multiplying the cell value by 1 in a for loop but this this did not seem to
work. i still get the green triangle next the cell indicating number stored
as text.

any help is appreciated.

bobm


--

Dave Peterson
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
Convert dates stored as text Emece Excel Discussion (Misc queries) 2 May 22nd 10 06:37 AM
Number stored as text Ana via OfficeKB.com Excel Worksheet Functions 3 October 14th 09 01:05 PM
Number stored as text GKW in GA Excel Discussion (Misc queries) 3 August 14th 08 05:53 PM
Number stored as text Andrew Clark Excel Discussion (Misc queries) 1 November 8th 05 10:25 PM
convert value stored as text to logical refrence value! Remote Desktop Connection hotkey Excel Worksheet Functions 2 August 1st 05 01:56 PM


All times are GMT +1. The time now is 10:40 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"