[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Perform multiplications on grey shaded cells using VBA

Posted on 2013-12-11
7
Medium Priority
?
325 Views
Last Modified: 2013-12-11
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
Comment
Question by:AndreasHermle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 39710970
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
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39710978
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
 

Author Comment

by:AndreasHermle
ID: 39710998
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
Technology Partners: 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!

 

Author Comment

by:AndreasHermle
ID: 39711000
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
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 39711020
I'll leave it to Saqibh then as he's pretty much done it already. :)
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 39711032
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
 

Author Closing Comment

by:AndreasHermle
ID: 39711107
ssaqibh:

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

Regards, Andreas
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question