You could try this macro
Option Explicit
Sub Test()
Dim MyRange As Range
Dim N As Integer
Dim NBinary As String
Dim RangeComb As Long
Dim X As Long
Dim Total As Long
Set MyRange = Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
MyRange.Interior.ColorIndex = xlNone
RangeComb = 2 ^ MyRange.Count
For N = 1 To RangeComb - 1
NBinary = Left("0000000000000000", Len(RangeComb) - Len(DecToBin(Str(N)))) & DecToBin(Str(N))
Total = 0
For X = 1 To MyRange.Count
If Mid(NBinary, X, 1) = "1" Then
Total = Total + MyRange(X)
End If
Next X
If Total = Range("A1") Then
For X = 1 To MyRange.Count
If Mid(NBinary, X, 1) = "1" Then
MyRange(X).Interior.ColorIndex = 4
Else
MyRange(X).Interior.ColorIndex = xlNone
End If
Next X
Exit Sub
End If
Next N
End Sub
Function DecToBin(ByRef D As String) As String
Dim N As Long
Dim Res As String
For N = 31 To 1 Step -1
Res = Res & IIf(CLng(D) And 2 ^ (N - 1), "1", "0")
Next N
N = InStr(1, Res, "1")
DecToBin = Mid(Res, IIf(N > 0, N, Len(Res)))
End Function
Open up the VBA editor by hitting ALT F11
Insert a new module by hitting Insert - Module
Paste the macro into the empty sheet
Hit ALT F11 to get back to the worksheet.
Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007/2010.
Bookmarks