Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Much help needed on conversion!


Hi there,

I'm currently working on a project .I will like to know if it is
possibe to actually convert text into certain numbers? An example will
be if user select ' system 1', upon clicking the macro button to update
sheet2 with the information, it will display '101' in sheet2. Meaning i
can define the text to convert into certain numerals.

like system 1 (in sheet 1) will become 200(set by me) in sheet 2 using
vba.

Thanks in advance!


--
oOpsy
------------------------------------------------------------------------
oOpsy's Profile: http://www.excelforum.com/member.php...o&userid=29132
View this thread: http://www.excelforum.com/showthread...hreadid=488525

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Much help needed on conversion!

That just sounds that you need to define a lookup table. Check VLOOKUP in
Help.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"oOpsy" wrote in
message ...

Hi there,

I'm currently working on a project .I will like to know if it is
possibe to actually convert text into certain numbers? An example will
be if user select ' system 1', upon clicking the macro button to update
sheet2 with the information, it will display '101' in sheet2. Meaning i
can define the text to convert into certain numerals.

like system 1 (in sheet 1) will become 200(set by me) in sheet 2 using
vba.

Thanks in advance!


--
oOpsy
------------------------------------------------------------------------
oOpsy's Profile:

http://www.excelforum.com/member.php...o&userid=29132
View this thread: http://www.excelforum.com/showthread...hreadid=488525



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Much help needed on conversion!


Thanks for the reply!

but vlookup is more of like a search function. I need something which
is like to decode let say this term 'voltage' into a numeral let's say
'101'


--
oOpsy
------------------------------------------------------------------------
oOpsy's Profile: http://www.excelforum.com/member.php...o&userid=29132
View this thread: http://www.excelforum.com/showthread...hreadid=488525

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Much help needed on conversion!


Function GetNumberFromString(InputString)

Dim InputString as string
Dim OutputNumber as integer

Select Case InputString

Case "String 1"

OutputNumber = 101

Case "String 2"

OutputNumber = 289

Case "String 3"

OutputNumber = 753

End Select

GetNumberFromString = OutputNumber

End Function


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=488525

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Much help needed on conversion!


Sorry,

remove Dim InputSting as strin

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Much help needed on conversion!

Do you mean that when you enter voltage, you want that cell translated?
Wouldn't you want to keep the original input, and have the translation
ancillary to that data?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"oOpsy" wrote in
message ...

Thanks for the reply!

but vlookup is more of like a search function. I need something which
is like to decode let say this term 'voltage' into a numeral let's say
'101'


--
oOpsy
------------------------------------------------------------------------
oOpsy's Profile:

http://www.excelforum.com/member.php...o&userid=29132
View this thread: http://www.excelforum.com/showthread...hreadid=488525



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Much help needed on conversion!


Kaak: Thanks for the code! I'm trying it out but do i place the code
under the module? Sorry abt this

Bob Phillips : Yeap i need to translate 'voltage' into numerals such a
'101' cos i'm creating this file whereby it will be read by my labvie
program which is only capable of reading in numerals . i want to le
users to just select 'voltage' instead of typing in all those numeral
which makes no sense to the

--
oOps
-----------------------------------------------------------------------
oOpsy's Profile: http://www.excelforum.com/member.php...fo&userid=2913
View this thread: http://www.excelforum.com/showthread.php?threadid=48852

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Much help needed on conversion!


It's a function

It should be in a module.
And you can call it from a macro like:

Sub Macro1

ReturnNumber = GetNumberFromString("String 2")

MsgBox(ReturnNumber)

End Sub

Function GetNumberFromString(InputString)

Dim InputString as string
Dim OutputNumber as integer

Select Case InputString

Case "String 1"

OutputNumber = 101

Case "String 2"

OutputNumber = 289

Case "String 3"

OutputNumber = 753

End Select

GetNumberFromString = OutputNumber

End Function


this should return a messagebox with 289 in it


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=488525

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Much help needed on conversion!

I think you want event code then. Change the range that the input applies to
and add the cases

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case "voltage": .Value = 101
Case "something": .Value = 200
Case "something else": .Value = 300
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"oOpsy" wrote in
message ...

Kaak: Thanks for the code! I'm trying it out but do i place the codes
under the module? Sorry abt this

Bob Phillips : Yeap i need to translate 'voltage' into numerals such as
'101' cos i'm creating this file whereby it will be read by my labview
program which is only capable of reading in numerals . i want to let
users to just select 'voltage' instead of typing in all those numerals
which makes no sense to them


--
oOpsy
------------------------------------------------------------------------
oOpsy's Profile:

http://www.excelforum.com/member.php...o&userid=29132
View this thread: http://www.excelforum.com/showthread...hreadid=488525



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
csv conversion Rozman Excel Discussion (Misc queries) 2 January 5th 10 06:44 PM
Conversion barrowhill Excel Discussion (Misc queries) 7 January 19th 09 12:03 AM
Deleting Rows With Non-Needed Data between Needed Data Daren Excel Worksheet Functions 2 September 30th 08 06:47 PM
Date Conversion Formula Needed Titanium Excel Worksheet Functions 20 September 16th 07 09:18 PM
conversion needed juster21[_4_] Excel Programming 1 July 29th 05 09:44 PM


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