ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro for converting number stored as "text" (or preceeded with ') to "number" formatting (https://www.excelbanter.com/excel-programming/365926-re-macro-converting-number-stored-text-preceeded-number-formatting.html)

markx

macro for converting number stored as "text" (or preceeded with ') to "number" formatting
 
Hello Duncan,

Hello everybody,



I've tried the solution with

activecell.value = activecell.value * 1

and it seems to work very good (thanks!!!)



Now, it still leaves me with some questions...

If I modify the code to:



Sub test()
Range("G2").Select
Do
ActiveCell.Value = ActiveCell.Value * 1
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell)
End Sub



....it will block/stop on the first cell that is not "number-like" (f. ex.
F64273/640ZUB/60407400) and put the warning box ["Type mismatch"].

Do you know how to tell VBA to skip such cases and continue until the end of
the column?



Thank you for your input!

Regards,

Mark





From: Duncan - view profile

Date: Fri, Jun 23 2006 4:15 pm

Email: "Duncan"

Groups: microsoft.public.excel.programming



Markx



A workaround I have used it to put



activecell.value = activecell.value * 1



Post back if this doesnt work (or if it does)



Duncan



--------------------------------------------------

From: markx - view profile

Date: Fri, Jun 23 2006 4:06 pm

Email: "markx"

Groups: microsoft.public.excel.programming



Hello,



I've tried to achieve this with macro recorder, but it writes only the

".select" part...

(I used to select the whole range and than pass through the contextual <!

menu that appears briefly on the left side of the cell and signals the

problem...)



What is the VBA instruction for this?

Many thanks,



Mark



P.S: Range("B3").Select

Selection.NumberFormat = "0.00"

is not functionning in my workbook neither...



Kaak[_78_]

macro for converting number stored as "text" (or preceeded with ') to "number" formatting
 

Sub test()
Range("G2").Select
Do
If Isnumeric(Trim(ActiveCell.Value)) Then ActiveCell.Value
Trim(ActiveCell.Value) * 1
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell)
End Su

--
Kaa
-----------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...nfo&userid=751
View this thread: http://www.excelforum.com/showthread.php?threadid=55725



All times are GMT +1. The time now is 07:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com