Extract Minimum Value and keep cell formatting

LeilaniMerle

New Member
Joined
Jan 26, 2014
Messages
22
Hi there,

I have a spreadsheet wherein I need to extract the minimum value from 4 Suppliers. The suppliers are colour coded, and i would like the extracted amount to show the suppliers colour code as well as the value.

I am merely using currently the Min function. Can anyone assist me?

QTYSupplier 1/UnitSupplier 1 \TotalSupplier 2/UnitSupplier 2 \TotalSupplier 3/UnitSupplier 3 \TotalSupplier 4/UnitSupplier 4 \TotalMinimum supplier
10A Circuit Breaker1012.45124.513.66136.617.55175.59.3393.39.33
25 A Circuit Breaker101.2012.007.6076.009.0090.005.0050.001.20
Plug Top Arrestor 16A102.4024.008.3083.006.0060.004.0040.002.40
Connector Strip 16A12W Black106.5065.009.5095.008.0080.007.0070.006.50
VEC 236 ELB Fluorescent Fitting203.3066.004.7094.007.00140.008.00160.003.30
VEC 258 ELB Fluorescent Fitting202.3046.006.20124.004.0080.006.00120.002.30
CLF Genie 11W/827 B22 PHI1501.60240.001.20180.002.00300.002.00300.001.20
CLF Genie 11W/827 E27 PHI1505.50825.004.00600.003.00450.005.00750.003.00
H/Saw Bld 18T BI-MET NICH206.20124.003.0060.001.0020.004.0080.001.00
Hacksaw BLD JUNIOR SPEAR103.9039.005.0050.005.0050.001.0010.001.00
SAM CB SF2-G DP 60A107.2072.007.0070.006.0060.003.0030.003.00
SAM CB SF3-G3 TP 30A CBI154.6069.008.90133.509.00135.008.00120.004.60
SAM CB SF2-G3 DP 15A CBI151.2018.008.90133.508.00120.009.00135.001.20
Surfix 2,5x3 + E WHI -100m2004.30860.006.001200.004.00800.006.001200.004.00
Ceen Ext Box 4x2 CT9052205.60112.003.5070.005.00100.005.00100.003.50
Ceen Ext Box 4x4 CT9054207.80156.002.4048.002.0040.004.0080.002.00
50W GU10 230V 36° Halogen2004.10820.007.601520.006.001200.002.00400.002.00
Surfix 1.5 2+E-100m2002.20440.008.101620.003.00600.001.00200.001.00
Surfix 2.5 2+E-100m20010.602120.005.301060.005.001000.004.00800.004.00
Candle Lamp 240V 40W/60W2008.401680.009.201840.007.001400.005.001000.005.00
Ballast Osram 2x36 EKB 2QT FIT 8209.70194.009.60192.008.00160.006.00120.006.00
Term DISCONN FEMALE FLAT1006.30630.007.10710.005.00500.003.00300.003.00
Term DISCONN MALE FLAT BLU1005.20520.004.00400.006.00600.002.00200.002.00
Lamp 400W HPS SON-T E40244.80115.203.0072.004.0096.007.00168.003.00
Wall Plug & Screw (Fischer Plugs)1009.60960.005.20520.002.00200.008.00800.002.00
Gland 1 PVC White204.2084.006.30126.006.00120.009.00180.004.20
Gland 0 PVC White201.3026.008.50170.001.0020.005.00100.001.00
VEC 218 ELB Fluorescent Fitting106.3063.001.4014.003.0030.006.0060.001.40
G4-20W-12V Halogen 2000hr504.10205.008.60430.009.00450.002.00100.002.00
Stove Plate Solid 8"409.50380.008.70348.006.00240.005.00200.005.00
Stove Solid 6" Solid 6"408.30332.001.3052.005.00200.002.0080.001.30
Lamp 240V 11W ES Mini1009.60960.004.50450.002.00200.004.00400.002.00
3kw Element & Thermostat KEG3A152.8042.006.2093.001.0015.003.0045.001.00
3Kw Geyser Spiral & Thermostat101.3013.001.2012.004.0040.006.0060.001.20
CRC 2005 2.26 Multipurpose57.5037.501.306.506.0030.001.005.001.00
Self Tapping Screw PAN HD1008.60860.001.40140.008.00800.008.00800.001.40
Self Tapping Screw PAN HD1005.80580.005.60560.009.00900.007.00700.005.60
Self Tap Screw 8x40mm1006.90690.008.90890.007.00700.009.00900.006.90
Fluor Tube 32 W Circline Eurolux204.2084.007.50150.005.00100.004.0080.004.00
Fluor Tube 40W Circline Eurolux202.2044.007.40148.003.0060.002.0040.002.00
SUB TOTAL EX VAT 219.5514732.20237.7614677.10217.5512361.50197.3311076.30
14% VAT 30.742062.5133.292054.7930.461730.6127.631550.68
TOTAL 250.2916794.71271.0516731.89
248.01
14092.11224.9612626.98


<colgroup><col><col><col span="7"><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
LeilaniMerle,

Welcome to the MrExcel forum.

What version of Excel and Windows are you using?


The suppliers are colour coded

Based on your text display, we have no way of telling what the cell colors are.


Can you post a screenshot of the actual raw data worksheet?

And, can you post a screenshot of the worksheet results (manually formatted by you) that you are looking for?

To post your data, you can download and install one of the following two programs:
Excel Jeanie
MrExcel HTML Maker

Or, when using Internet Explorer, just put borders around your data in Excel and copy those cells into your post.
See reply #2 the BLUE text in the following link:
http://www.mrexcel.com/forum/about-board/444901-how-create-table-like-aladin.html#post2198045


If you are not able to give us screenshots:
You can upload your workbook to Box Net,
sensitive data changed
mark the workbook for sharing
and provide us with a link to your workbook.
 
Upvote 0
LeilaniMerle,

Sample raw data before the macro (the colors in row 1 may not match your colors):


Excel 2007
ABCDEFGHIJK
1QTYSupplier 1/UnitSupplier 1 \TotalSupplier 2/UnitSupplier 2 \TotalSupplier 3/UnitSupplier 3 \TotalSupplier 4/UnitSupplier 4 \TotalMinimum supplier
210A Circuit Breaker1012.45124.513.66136.617.55175.59.3393.3
325 A Circuit Breaker101.2127.676990550
4Plug Top Arrestor 16A102.4248.383660440
5Connector Strip 16A12W Black106.5659.595880770
6VEC 236 ELB Fluorescent Fitting203.3664.79471408160
7VEC 258 ELB Fluorescent Fitting202.3466.21244806120
8CLF Genie 11W/827 B22 PHI1501.62401.218023002300
9CLF Genie 11W/827 E27 PHI1505.5825460034505750
10H/Saw Bld 18T BI-MET NICH206.2124360120480
11Hacksaw BLD JUNIOR SPEAR103.939550550110
12SAM CB SF2-G DP 60A107.272770660330
13SAM CB SF3-G3 TP 30A CBI154.6698.9133.591358120
14SAM CB SF2-G3 DP 15A CBI151.2188.9133.581209135
15Surfix 2,5x3 + E WHI -100m2004.386061200480061200
16Ceen Ext Box 4x2 CT9052205.61123.57051005100
17Ceen Ext Box 4x4 CT9054207.81562.448240480
1850W GU10 230V 36 Halogen2004.18207.61520612002400
19Surfix 1.5 2+E-100m2002.24408.1162036001200
20Surfix 2.5 2+E-100m20010.621205.31060510004800
21Candle Lamp 240V 40W/60W2008.416809.218407140051000
22Ballast Osram 2x36 EKB 2QT FIT 8209.71949.619281606120
23Term DISCONN FEMALE FLAT1006.36307.171055003300
24Term DISCONN MALE FLAT BLU1005.2520440066002200
25Lamp 400W HPS SON-T E40244.8115.23724967168
26Wall Plug & Screw (Fischer Plugs)1009.69605.252022008800
27Gland 1 PVC White204.2846.312661209180
28Gland 0 PVC White201.3268.51701205100
29VEC 218 ELB Fluorescent Fitting106.3631.414330660
30G4-20W-12V Halogen 2000hr504.12058.643094502100
31Stove Plate Solid 8"409.53808.734862405200
32Stove Solid 6" Solid 6"408.33321.3525200280
33Lamp 240V 11W ES Mini1009.69604.545022004400
343kw Element & Thermostat KEG3A152.8426.293115345
353Kw Geyser Spiral & Thermostat101.3131.212440660
36CRC 2005 2.26 Multipurpose57.537.51.36.563015
37Self Tapping Screw PAN HD1008.68601.414088008800
38Self Tapping Screw PAN HD1005.85805.656099007700
39Self Tap Screw 8x40mm1006.96908.989077009900
40Fluor Tube 32 W Circline Eurolux204.2847.51505100480
41Fluor Tube 40W Circline Eurolux202.2447.4148360240
42
43SUB TOTAL EX VAT219.5514732.2237.7614677.1217.5512361.5197.3311076.3197.33
4414% VAT30.742062.5133.292054.7930.461730.6127.631550.6827.63
45TOTAL250.2916794.71271.0516731.89248.0114092.11224.9612626.98224.96
46
Sheet1


After the macro:


Excel 2007
ABCDEFGHIJK
1QTYSupplier 1/UnitSupplier 1 \TotalSupplier 2/UnitSupplier 2 \TotalSupplier 3/UnitSupplier 3 \TotalSupplier 4/UnitSupplier 4 \TotalMinimum supplier
210A Circuit Breaker1012.45124.513.66136.617.55175.59.3393.39.33
325 A Circuit Breaker101.2127.6769905501.2
4Plug Top Arrestor 16A102.4248.3836604402.4
5Connector Strip 16A12W Black106.5659.5958807706.5
6VEC 236 ELB Fluorescent Fitting203.3664.794714081603.3
7VEC 258 ELB Fluorescent Fitting202.3466.212448061202.3
8CLF Genie 11W/827 B22 PHI1501.62401.2180230023001.2
9CLF Genie 11W/827 E27 PHI1505.58254600345057503
10H/Saw Bld 18T BI-MET NICH206.21243601204801
11Hacksaw BLD JUNIOR SPEAR103.9395505501101
12SAM CB SF2-G DP 60A107.2727706603303
13SAM CB SF3-G3 TP 30A CBI154.6698.9133.5913581204.6
14SAM CB SF2-G3 DP 15A CBI151.2188.9133.5812091351.2
15Surfix 2,5x3 + E WHI -100m2004.3860612004800612004
16Ceen Ext Box 4x2 CT9052205.61123.570510051003.5
17Ceen Ext Box 4x4 CT9054207.81562.4482404802
1850W GU10 230V 36 Halogen2004.18207.615206120024002
19Surfix 1.5 2+E-100m2002.24408.11620360012001
20Surfix 2.5 2+E-100m20010.621205.310605100048004
21Candle Lamp 240V 40W/60W2008.416809.2184071400510005
22Ballast Osram 2x36 EKB 2QT FIT 8209.71949.6192816061206
23Term DISCONN FEMALE FLAT1006.36307.1710550033003
24Term DISCONN MALE FLAT BLU1005.25204400660022002
25Lamp 400W HPS SON-T E40244.8115.237249671683
26Wall Plug & Screw (Fischer Plugs)1009.69605.2520220088002
27Gland 1 PVC White204.2846.3126612091804.2
28Gland 0 PVC White201.3268.517012051001
29VEC 218 ELB Fluorescent Fitting106.3631.4143306601.4
30G4-20W-12V Halogen 2000hr504.12058.6430945021002
31Stove Plate Solid 8"409.53808.7348624052005
32Stove Solid 6" Solid 6"408.33321.35252002801.3
33Lamp 240V 11W ES Mini1009.69604.5450220044002
343kw Element & Thermostat KEG3A152.8426.2931153451
353Kw Geyser Spiral & Thermostat101.3131.2124406601.2
36CRC 2005 2.26 Multipurpose57.537.51.36.5630151
37Self Tapping Screw PAN HD1008.68601.4140880088001.4
38Self Tapping Screw PAN HD1005.85805.6560990077005.6
39Self Tap Screw 8x40mm1006.96908.9890770099006.9
40Fluor Tube 32 W Circline Eurolux204.2847.515051004804
41Fluor Tube 40W Circline Eurolux202.2447.41483602402
42
43SUB TOTAL EX VAT219.5514732.2237.7614677.1217.5512361.5197.3311076.3197.33
4414% VAT30.742062.5133.292054.7930.461730.6127.631550.6827.63
45TOTAL250.2916794.71271.0516731.89248.0114092.11224.9612626.98224.96
46
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Option Explicit
Sub GetMinColor()
' hiker95, 01/26/2014, ME753096
Dim r As Long, lr As Long, rng As Range, fminrng As Range
Dim myminv As Double
Application.ScreenUpdating = False
lr = Range("A2").End(xlDown).Row
For r = 2 To lr
  Set rng = Application.Union(Range("C" & r), Range("E" & r), Range("G" & r), Range("I" & r))
  myminv = WorksheetFunction.Min(rng)
  Set fminrng = rng.Find(myminv, LookAt:=xlWhole)
  If Not fminrng Is Nothing Then
    Cells(r, 11) = myminv
    Cells(r, 11).Interior.Color = Cells(1, fminrng.Column).Interior.Color
  End If
Next r
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the GetMinColor macro.
 
Upvote 0
hiker95, It worked brilliantly. Many many thanks. Hours of worked saved. I am delighted. Chat soon.

Leilani

Oops, sorry. The macro to get colours worked great. But the minute i run the macro my sum function is overwritten. my sum is e.g. in K2 =MIN(C2,E2,G2,I2).

Please know that the Items and qty's and unit prices etc. are all changeable. So it would need to update value output as new values are entered.

I am working in MS Office Excel 2010

Thanks
Leilani
 
Last edited:
Upvote 0
LeilaniMerle,

Thanks for the formulae - it does make a difference.

Not all columns are shown because we are missing the Total columns formulae.

And, if I understand your correctly.

Sample raw data before the macro (the colors in row 1 may not match your colors) (the BLUE cells are the minimums) (the YELLOW cells are the maximums):


Excel 2007
ABCEGIKL
1QTYSupplier 1/UnitSupplier 2/UnitSupplier 3/UnitSupplier 4/UnitMinimum supplier
210A Circuit Breaker1012.4513.6617.59.339.33
325 A Circuit Breaker101.27.6951.2
4Plug Top Arrestor 16A102.48.3642.4
5Connector Strip 16A12W Black106.59.5876.5
6VEC 236 ELB Fluorescent Fitting203.34.7783.3
7VEC 258 ELB Fluorescent Fitting202.36.2462.3
8CLF Genie 11W/827 B22 PHI1501.61.2221.2
Sheet1
Cell Formulas
RangeFormula
K2=MIN(C2,E2,G2,I2)


If we then run the macro, we get this:


Excel 2007
ABCEGIKL
1QTYSupplier 1/UnitSupplier 2/UnitSupplier 3/UnitSupplier 4/UnitMinimum supplier
210A Circuit Breaker1012.4513.6617.59.339.33
325 A Circuit Breaker101.27.6951.2
4Plug Top Arrestor 16A102.48.3642.4
5Connector Strip 16A12W Black106.59.5876.5
6VEC 236 ELB Fluorescent Fitting203.34.7783.3
7VEC 258 ELB Fluorescent Fitting202.36.2462.3
8CLF Genie 11W/827 B22 PHI1501.61.2221.2
Sheet1
Cell Formulas
RangeFormula
K2=MIN(C2,E2,G2,I2)


Then if we change the YELLOW cells, and, run the macro again we get this:


Excel 2007
ABCEGIKL
1QTYSupplier 1/UnitSupplier 2/UnitSupplier 3/UnitSupplier 4/UnitMinimum supplier
210A Circuit Breaker1012.4513.661.119.331.11
325 A Circuit Breaker101.21.11951.11
4Plug Top Arrestor 16A102.48.3642.4
5Connector Strip 16A12W Black106.59.5876.5
6VEC 236 ELB Fluorescent Fitting203.34.7783.3
7VEC 258 ELB Fluorescent Fitting202.36.2462.3
8CLF Genie 11W/827 B22 PHI1501.61.2221.2
Sheet1
Cell Formulas
RangeFormula
K2=MIN(C2,E2,G2,I2)


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Option Explicit
Sub GetMinColorV2()
' hiker95, 01/27/2014, ME753096
Dim lr As Long, c As Range, rng As Range, fminrng As Range
Application.ScreenUpdating = False
lr = Range("K2").End(xlDown).Row
With Range("K2:K" & lr).Interior
  .Pattern = xlNone
  .TintAndShade = 0
  .PatternTintAndShade = 0
End With
For Each c In Range("K2:K" & lr)
  If c <> "" Then
    Set rng = Application.Union(Range("C" & c.Row), Range("E" & c.Row), Range("G" & c.Row), Range("I" & c.Row))
    Set fminrng = rng.Find(c.Value, LookAt:=xlWhole)
    If Not fminrng Is Nothing Then
      c.Interior.Color = Cells(1, fminrng.Column).Interior.Color
    End If
  End If
Next c
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the GetMinColorV2 macro.
 
Last edited:
Upvote 0
hiker I want to thank you so much. You have been terrific. All is working just as I need it to. You are a genius. Thank you for your patience with me, and for speaking a layman's language so I could understand. No doubt I will be frequenting these forums. So see you soon. You too, have an awesome day... LM x x x
 
Upvote 0
LeilaniMerle,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,684
Members
449,048
Latest member
81jamesacct

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