Complete a Range Shape Fill (with the color grey) on a sheet in one workbook, based on a number in a table in a different workbook

Roo2021

New Member
Joined
Feb 10, 2021
Messages
8
Office Version
  1. 2010
Platform
  1. Windows
Morning All,

I've got the following table on sheet 'DATA' in one work book and based on the figures in cells B30, C30, D30, E30, F30, G30 & H30 ( where the numbers can be anything between 1 and 22),

1665140130235.png


I want to colour fill the applicable circle on sheet 'TRIM' in a different workbook against the numbered circle/area:

1665140753021.png



But if cell B32 on sheet 'DATA' says 'none' I do not need to fill any circles on sheet 'TRIM':

1665140693199.png


I have used 'IF' 'ELSE' coding before and through recording a macro, I was able to colour a circle in the 'TRIM' sheet (all be it red):

1665140969338.png


But am struggling to piece it all together, has anybody got any ideas?

Many Thanks
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Roo2021,

First, You would probably get a better response on this forum if instead of the images you furnished you used the XL2BB format, which makes the portions of worksheets DATA and TRIM downloadable. To see how that works go to this link: XL2BB tool which is in the Guidelines for Posting and Forum Use Tips.
This will allow someone to not have to create your DATA and to see the names of each circle/oval (Shape) on sheet TRIM by selecting each shape.

Second, It appears that you are working off worksheet DATA and applying said data to the shapes on worksheet TRIM...in the 'same' workbook. If this is not the case, then we need the Names of each Workbook before we continue in case you are indeed working with different workbooks.

Below is some code I prepared assuming both DATA and TRIM worksheets are in the same workbook.
You try putting the code in a copy of your workbook so you don't loose anything.
Perpa

VBA Code:
Sub FillNumberedOvals()

Dim shp As Excel.Shape
Dim ws As Worksheet
Dim ovn As Integer
Dim col As Integer

Set ws = ActiveSheet 'Assumes you are looking at worksheet "DATA"

If Cells(32, 2) = "NONE" Then Exit Sub 'No fill required

For col = 2 To 8
ovn = Cells(30, col) 'These are the values in row 30 on DATA worksheet to be colored, Oval Numbers

If ovn > 0 = True Then 'Checks each value in row 30 to see if it is a number
Worksheets("TRIM").Select

For Each shp In Worksheets("TRIM").Shapes
If shp.Name = "Oval " & ovn Then
shp.Select

With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(204, 204, 255)
.Transparency = 0
.Solid
End With

               GoTo Passem

          End If
Next
Passem:

      Cells(10, 3).Select
      Worksheets("DATA").Select
   End If
Next

   Cells(25, "C").Select 'Go to cell C25 when done, also unselects last oval that was colored
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top