ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   conversion (https://www.excelbanter.com/excel-programming/364825-conversion.html)

Hemant_india[_2_]

conversion
 
hi
i have written follwing code

Private Sub CommandButton1_Click()
Dim rng As Range
Set rng = ActiveSheet.Range("g:g")
For Each col In rng
col.Value = nconvert(col.Text)
Next col

'TextBox1.Text = nconvert("3500000")

End Sub
====
Function nconvert(tsh) As String
If tsh < 0 Then ' Evaluate argument.
Exit Function ' Exit to calling procedure.
Else
leftside = Left(tsh, Len(tsh) - Len(Right(tsh, 2)))
nconvert = CStr(leftside) & "." & CStr(Right(tsh, 2))

End If
End Function
my problem is if this code is run again and again
amount will go on reducing
please suggest otherwise
--
hemu

Charlie

conversion
 
Private Sub CommandButton1_Click()

Dim Cell As Range

For Each Cell In ActiveSheet.Range("G:G")
Cell = nConvert(Cell.Value)
Next Cell

End Sub

Function nConvert(str As String) As String

If str < "" Then nConvert = Left(str, Len(str) - Len(Right(str, 2))) & "."
& Right(str, 2)

End Function


"Hemant_india" wrote:

hi
i have written follwing code

Private Sub CommandButton1_Click()
Dim rng As Range
Set rng = ActiveSheet.Range("g:g")
For Each col In rng
col.Value = nconvert(col.Text)
Next col

'TextBox1.Text = nconvert("3500000")

End Sub
====
Function nconvert(tsh) As String
If tsh < 0 Then ' Evaluate argument.
Exit Function ' Exit to calling procedure.
Else
leftside = Left(tsh, Len(tsh) - Len(Right(tsh, 2)))
nconvert = CStr(leftside) & "." & CStr(Right(tsh, 2))

End If
End Function
my problem is if this code is run again and again
amount will go on reducing
please suggest otherwise
--
hemu



All times are GMT +1. The time now is 05:06 AM.

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