ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Convert to number (https://www.excelbanter.com/excel-programming/347115-convert-number.html)

JakeyC

Convert to number
 
Hi all -

I have a spreadsheet which queries an external database. On returning
the data, it treats numbers as text. The drop-down 'error arrow'
appears, inviting me to convert it to a number, which is exactly what I
want to do.

I need this to be done every time, so I tried recording a Macro to run
for me when I chose to convert it but no code was generated by the
macro recorder.

Does anyone know what code I need to use to simulate this error
correcting feature?


Gary''s Student

Convert to number
 
Without code:

Put a 1 in an un-used cell and copy the cell.
Select the cells you want to convert and paste/special with the multiply
button checked.

With code:

Sub Macro1()
Dim r As Range
For Each r In Selection
r.Value = 1# * r.Value
Next
End Sub

--
Gary's Student


"JakeyC" wrote:

Hi all -

I have a spreadsheet which queries an external database. On returning
the data, it treats numbers as text. The drop-down 'error arrow'
appears, inviting me to convert it to a number, which is exactly what I
want to do.

I need this to be done every time, so I tried recording a Macro to run
for me when I chose to convert it but no code was generated by the
macro recorder.

Does anyone know what code I need to use to simulate this error
correcting feature?




All times are GMT +1. The time now is 09:20 AM.

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