[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

Perform multiplications on grey shaded cells using VBA

Dear Experts:

I would like to perform the following action using VBA on the current workbook

... Look for grey shaded cells (RGB 222, 222, 222) in all worksheets of the current workbook with exception of one named 'MasterSheet'
... If found perform the following multiplication:
C5 (Cell reference in worksheet 'MasterSheet') times the value found in that grey shaded cell
... Do the loop with this multiplication.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
AndreasHermle
Asked:
AndreasHermle
  • 3
  • 2
  • 2
1 Solution
 
Rory ArchibaldCommented:
Andreas,

Do you mean replace the value in the shaded cell with itself multiplied by C5 on the master sheet, or something else? "Do the loop with this multiplication." isn't really clear to me.

Regards,
Rory
0
 
Saqib Husain, SyedEngineerCommented:
Sub mulgrey()
    Dim cel As Range
    For Each cel In ActiveSheet.UsedRange.Cells
        If cel.Interior.Color = RGB(222, 222, 222) Then
            cel.Value = Sheets("Mastersheet").Range("C5") * cel.Value
        End If
    Next cel
End Sub
0
 
AndreasHermleAuthor Commented:
Hi Roy,

ok, the requirements were not clear, I have to admit.

It is: the value in the grey shaded cell times C5 (MasterSheet)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
AndreasHermleAuthor Commented:
Hi ssaqibh:

we are almost there, thank you very much. The multiplication is only performed on the active sheet, but there are grey shaded cells in all worksheets. The multiplication is not to be performed in the 'MasterSheet' worksheet.

Thank you, Regards, Andreas
0
 
Rory ArchibaldCommented:
I'll leave it to Saqibh then as he's pretty much done it already. :)
0
 
Saqib Husain, SyedEngineerCommented:
Sorry, I missed the "All worksheets" part.

Sub mulgrey()
    Dim cel As Range
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        If ws.Name <> "Mastersheet" Then
            For Each cel In ws.UsedRange.Cells
                If cel.Interior.Color = RGB(222, 222, 222) Then
                    cel.Value = Sheets("Mastersheet").Range("C5") * cel.Value
                End If
            Next cel
        End If
    Next ws
End Sub
0
 
AndreasHermleAuthor Commented:
ssaqibh:

great this did the trick. Thank you very much for your professional help.

Regards, Andreas
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now