P
pcorcele
Hi
I have this macro that checks the values of the various cell starting from "CURRENT RANGE"
I would like very much to have the macro start count at the current location of the cursor. Can anyone help with this
Thanks
Ian M
Dim i As Integer
Dim MyText As String, List, myTotal As Double
Dim Cell As Range, rng As Range
Set rng = Range("currentrange")
rng.Select
Set cmt = ActiveSheet.Comments
Selection.SpecialCells(xlCellTypeComments).Select
For Each Cell In Selection
Cell.Select
myTotal = 0
MyText = Cell.Comment.Text
If Selection.Interior.Color = 16711680 Then
Selection.Font.Color = -16711681
Selection.Font.TintAndShade = 0
Else
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
End If
If InStr(MyText, "?") Then
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
End If
MyText = MyText + " "
'look for "="
For z1% = 1 To Len(MyText)
If Mid(MyText, z1%, 1) = "=" Then
'look for value
Value$ = ""
For z2% = z1% + 1 To Len(MyText)
If IsNumeric(Mid(MyText, z2%, 1)) Then
Value$ = Value$ + Mid(MyText, z2%, 1)
Else
If Value$ <> "" Then myTotal = myTotal + Val(Value$): z1% = z2%: Exit For
End If
Next
End If
'ActiveCell.FormulaR1C1 = myTotal
Next
ActiveCell.FormulaR1C1 = myTotal
Next
End Sub
I have this macro that checks the values of the various cell starting from "CURRENT RANGE"
I would like very much to have the macro start count at the current location of the cursor. Can anyone help with this
Thanks
Ian M
Dim i As Integer
Dim MyText As String, List, myTotal As Double
Dim Cell As Range, rng As Range
Set rng = Range("currentrange")
rng.Select
Set cmt = ActiveSheet.Comments
Selection.SpecialCells(xlCellTypeComments).Select
For Each Cell In Selection
Cell.Select
myTotal = 0
MyText = Cell.Comment.Text
If Selection.Interior.Color = 16711680 Then
Selection.Font.Color = -16711681
Selection.Font.TintAndShade = 0
Else
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
End If
If InStr(MyText, "?") Then
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
End If
MyText = MyText + " "
'look for "="
For z1% = 1 To Len(MyText)
If Mid(MyText, z1%, 1) = "=" Then
'look for value
Value$ = ""
For z2% = z1% + 1 To Len(MyText)
If IsNumeric(Mid(MyText, z2%, 1)) Then
Value$ = Value$ + Mid(MyText, z2%, 1)
Else
If Value$ <> "" Then myTotal = myTotal + Val(Value$): z1% = z2%: Exit For
End If
Next
End If
'ActiveCell.FormulaR1C1 = myTotal
Next
ActiveCell.FormulaR1C1 = myTotal
Next
End Sub