Solved

Perform multiplications on grey shaded cells using VBA

Posted on 2013-12-11
7
284 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:AndreasHermle
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
ssaqibh:

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

Regards, Andreas
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now