Consulting

Results 1 to 2 of 2

Thread: Solved: Macro to calculate only in cells filled with blue color

  1. #1

    Question Solved: Macro to calculate only in cells filled with blue color

    I have a macro (I got it here actually, just made some small modifications) which is working brilliantly!

    This is the code:
    Sub EuroConverter()
        Dim xchg As Single, ocel As Range
        'Application.ScreenUpdating = False
        xchg = 270.4885346
        On Error Resume Next
        For Each ocel In Selection
            If ocel <> "" And IsNumeric(ocel.Value) Then
            ocel.Value = Round(ocel.Value / xchg)
            Else:
        End If
        Next
        'Application.ScreenUpdating = True
    End Sub
    What it does, it changes the amounts in the selected cells. However I would like to upgrade it a bit, but I do not know if it is possible...

    What I would like, is that the macro to work on the same principle, but only to execute the calculation in the cells which are filled with light blue color (color index = 34). Is it possible? I use excel 2007.
    If you can, please try to help!

    Thank you in advance!
    Last edited by hunsnowboard; 11-09-2010 at 03:51 AM.

  2. #2
    Thank you very much, but I figured out myself! Wohooo! Thanks!
    Sub EuroConverter_color()
    Dim xchg As Single, ocel As Range
    'Application.ScreenUpdating = False
    xchg = 270.4885346
    On Error Resume Next
    For Each ocel In Selection
    If ocel <> "" And IsNumeric(ocel.Value) And ocel.Interior.ColorIndex = 34 Then
    ocel.Value = Round(ocel.Value / xchg)
    Else:
    End If
    Next
    'Application.ScreenUpdating = True
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •