ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Much help needed on conversion! (https://www.excelbanter.com/excel-programming/346702-much-help-needed-conversion.html)

oOpsy

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. :confused:

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


Bob Phillips[_6_]

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. :confused:

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




oOpsy[_2_]

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


Kaak[_46_]

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


Kaak[_47_]

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


Bob Phillips[_6_]

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




oOpsy[_3_]

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


Kaak[_49_]

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


Bob Phillips[_6_]

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




oOpsy[_4_]

Much help needed on conversion!
 

thanks both for the help! manage to test out both codes and both works!

thanks again!;)


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



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

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