PC Review


Reply
Thread Tools Rate Thread

Convert numeric field from type 1 to type 2

 
 
u473
Guest
Posts: n/a
 
      19th Oct 2008
My Lookup does not work because the LookUp field is sometimes of type
1 and sometimes type 2
I tried to fix that in the initial import step by converting the
culprit field to a string as follows :
..
Sub Convert()
Dim LastRow As Integer
LastRow = Range("E65335").End(xlUp).Row
Range("E1:E" & LastRow).NumberFormat = "@"
End Sub
..
The result leads me to believe that the conversion took place because
the data is now is Left-Aligned.
However the data type in that field is still unchanged.
Data in my source field in sometimes Numeric like 51693, sometimes
AlphaNumeric like TN101,
I need to have all that field converted to String or Text.
..
Thank you for your help,
..
J.P.
 
Reply With Quote
 
 
 
 
Sheeloo
Guest
Posts: n/a
 
      19th Oct 2008
You do not need to convert everything to text to make VLOOKUP work...

Instead of
=VLOOKUP(A1,...)
Use
=VLOOKUP(TEXT(A1,"#"),...
if your lookup range has text and A1 has a number...
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"u473" wrote:

> My Lookup does not work because the LookUp field is sometimes of type
> 1 and sometimes type 2
> I tried to fix that in the initial import step by converting the
> culprit field to a string as follows :
> ..
> Sub Convert()
> Dim LastRow As Integer
> LastRow = Range("E65335").End(xlUp).Row
> Range("E1:E" & LastRow).NumberFormat = "@"
> End Sub
> ..
> The result leads me to believe that the conversion took place because
> the data is now is Left-Aligned.
> However the data type in that field is still unchanged.
> Data in my source field in sometimes Numeric like 51693, sometimes
> AlphaNumeric like TN101,
> I need to have all that field converted to String or Text.
> ..
> Thank you for your help,
> ..
> J.P.
>

 
Reply With Quote
 
u473
Guest
Posts: n/a
 
      20th Oct 2008
I do appreciate this VLOOKUP tip as I will have the use for it.
However I would like to fix the data type in my initial Import step
with VBA in order to have all data type for that field as type 2.
But I read in another post from Tom Ogilvy : "In general, you can't
force a change in type in VBA the way you can in Excel..."
I could accept that if the conversion was applied within the Cell
within the same Sheet,
but I am reading data in workbook A, converting and writing it in
workbook B. What is the work around solution ?
Thank you for your help,
J.P.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Import Convert Data Type from Type 1 to Type 2 u473 Microsoft Excel Programming 3 21st Oct 2008 08:22 PM
How can I convert System.Type variables to some database data type? lichaoir Microsoft C# .NET 0 12th Mar 2008 03:35 AM
error C2665 :none of the number1 overloads can convert parameter number2 from type 'type' Joseph Lu Microsoft VC .NET 2 17th Jul 2006 01:35 PM
How to convert contents of column from numeric data type to text moondaddy Microsoft Excel Discussion 6 29th Apr 2006 11:54 PM
how to convert a range from numeric to text type? but quickly lauralucas@gmail.com Microsoft Excel Programming 4 27th Apr 2006 09:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 AM.