LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default converting a string to long

In the bit of code below
The msgbox near the end returns DividingCell as 2.134
but when I try to convert to a long as DividingNum its value is only 0?
How do I make DividingNum's value equal to 2.134

Regards,
Ciarán

Private Sub CommandButton1_Click()
Dim EndCell As String
Dim EndRow As Long
Dim CurrentCell As String
Dim CurrentRow As Long
Dim DividingCell As String
Dim DividingNum As Long

'Find the co-ords of last Col and row and put them into an integer
ActiveCell.SpecialCells(xlLastCell).Select
EndCell = ActiveCell.Address(, , xlR1C1)
MsgBox (EndCell)

If Mid(EndCell, 3, 1) = "C" Then
EndRow = CLng(Mid(EndCell, 2, 1))

ElseIf Mid(EndCell, 4, 1) = "C" Then
EndRow = CLng(Mid(EndCell, 2, 2))

ElseIf Mid(EndCell, 5, 1) = "C" Then
EndRow = CLng(Mid(EndCell, 2, 3))

ElseIf Mid(EndCell, 6, 1) = "C" Then
EndRow = CLng(Mid(EndCell, 2, 4))

ElseIf Mid(EndCell, 7, 1) = "C" Then
EndRow = CLng(Mid(EndCell, 2, 5))



End If
MsgBox (EndRow)



Range("F4").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
CurrentCell = ActiveCell.Address(, , xlR1C1)
MsgBox (CurrentCell)

If Mid(CurrentCell, 3, 1) = "C" Then
CurrentRow = CLng(Mid(CurrentCell, 2, 1))

ElseIf Mid(CurrentCell, 4, 1) = "C" Then
CurrentRow = CLng(Mid(CurrentCell, 2, 2))

ElseIf Mid(CurrentCell, 5, 1) = "C" Then
CurrentRow = CLng(Mid(CurrentCell, 2, 3))

ElseIf Mid(CurrentCell, 6, 1) = "C" Then
CurrentRow = CLng(Mid(CurrentCell, 2, 4))

ElseIf Mid(CurrentCell, 7, 1) = "C" Then
CurrentRow = CLng(Mid(CurrentCell, 2, 5))



End If
MsgBox (CurrentRow)

Range("c" & CurrentRow).Select

Selection.End(xlUp).Select

DividingCell = ActiveCell



MsgBox (DividingCell)
DividingNum = CLng(DividingCell)
MsgBox (DividingNum)

'MsgBox ("about to do calc")
'
'Range("g" & CurrentRow).Select
'
'
'MsgBox ("calc shud be done now")









End Sub
 
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
Extracting certain characters from a long string Stan in South Africa Excel Worksheet Functions 4 June 26th 08 08:35 PM
Long string of IF formulas changetires Excel Discussion (Misc queries) 3 June 21st 06 08:59 PM
How do I specific digits in a long string? PhilGTI Excel Discussion (Misc queries) 2 February 21st 05 05:21 PM
Transposing a Long String carl Excel Worksheet Functions 2 January 3rd 05 02:55 PM
Type mismatch? string 2 a long?? CAA[_2_] Excel Programming 4 December 9th 03 02:34 PM


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