C
Ciar?n
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
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