Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cell Translation Code

I want to use the change event of the worksheet object, add code that
will take the numeric value entered in the cell, for instance, 55678
and translate the number to 556.78 automatically. I have code that
works, but I keep getting a type mismatch error when I convert the
number to a string and back again. If I don't convert, I get
something like this, 556..78. If I convert, i get a type mismatch,
however the code continues to work and I get 556.78, only I get a type
mismatch error.

Dim v1 as String
Dim v2 as String
Dim v3 as String

v1 = Right(target.value,2)
v2 = Left(target.value,Len(target.value)-2)
v3 = v2 & "." v1
target .value = v3

any suggestions are appreciated.

stan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Cell Translation Code

If I'm understanding, you want a result that's the original number divided
by 100. If that's correct then this works:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Application.IsNumber(Target) Then
Application.EnableEvents = False
Target.Value = Target.Value / 100
Application.EnableEvents = True
End If

End Sub

hth,

Doug

wrote in message
om...
I want to use the change event of the worksheet object, add code that
will take the numeric value entered in the cell, for instance, 55678
and translate the number to 556.78 automatically. I have code that
works, but I keep getting a type mismatch error when I convert the
number to a string and back again. If I don't convert, I get
something like this, 556..78. If I convert, i get a type mismatch,
however the code continues to work and I get 556.78, only I get a type
mismatch error.

Dim v1 as String
Dim v2 as String
Dim v3 as String

v1 = Right(target.value,2)
v2 = Left(target.value,Len(target.value)-2)
v3 = v2 & "." v1
target .value = v3

any suggestions are appreciated.

stan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Cell Translation Code

Why not just use:

Tools | Options | Edit | Fixed Decimal | Places = 2

?

--

Vasant

wrote in message
om...
I want to use the change event of the worksheet object, add code that
will take the numeric value entered in the cell, for instance, 55678
and translate the number to 556.78 automatically. I have code that
works, but I keep getting a type mismatch error when I convert the
number to a string and back again. If I don't convert, I get
something like this, 556..78. If I convert, i get a type mismatch,
however the code continues to work and I get 556.78, only I get a type
mismatch error.

Dim v1 as String
Dim v2 as String
Dim v3 as String

v1 = Right(target.value,2)
v2 = Left(target.value,Len(target.value)-2)
v3 = v2 & "." v1
target .value = v3

any suggestions are appreciated.

stan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cell Translation Code

Thank you for you help. I can't use the property in Tools Options
because only certain cells can be affected.

I did not even consider target.value / 100, i think that might work.

stan
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
Cell formula translation Shell Excel Worksheet Functions 2 February 26th 10 04:16 PM
Code translation please N.F[_2_] Excel Discussion (Misc queries) 0 July 6th 07 12:42 AM
& function cell format translation. [email protected] Excel Discussion (Misc queries) 3 April 7th 06 12:18 PM
XlPrevious Translation Code Steve Barwood Excel Programming 2 January 15th 04 03:31 PM
Need Translation Phil Hageman Excel Programming 1 July 25th 03 03:19 PM


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

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"