string and number in the same column

  • Thread starter Thread starter Grey
  • Start date Start date
G

Grey

I know i can use str() function convert the number into string type for one
column, but the column also has some values of string type, so i got an
error when i try to convert this column with str(). my question how can i
convert a column which has number and string with some function??


Million Thanks
 
Erick,

It would have helped to see your code, but you can do something like the
code below, which will step through a selection.

HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim myCell As Range
For Each myCell In Selection
On Error GoTo WasString
MsgBox Str(myCell.Value)
GoTo WasNumber
WasString:
MsgBox myCell.Value
Resume Next
WasNumber:
Next myCell
End Sub
 
If your data is in column A put this formula in column B.

=IF(ISTEXT(A1),A1,TEXT(A1,0))
 
Back
Top