Macro help

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top