![]() |
|
#1
|
|||
|
|||
![]()
in D50 enter formula =SUM(D34: D46)
in D52 enter formula =D50-D48 in G50 enter formula =SUM(G34:G46) in G52 enter formula =G50-G48 Code:
Sub sbRangeFillColorExample3() ' reset/clear button Range("B34:h46").Interior.Color = RGB(255, 255, 255) Range("D48").Formula = "=SUM(D34:D46)" Range("G48").Formula = "=SUM(G34:G46)" End Sub Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'limit to single cell If Target.Count > 1 Then Exit Sub 'limit to Company column If Intersect(Target, Range("B34:B46")) Is Nothing Then Exit Sub ' ok to continue Intersect(Target.EntireRow, Range("B33:H46")).Cells.Interior.Color = RGB(255, 255, 9) Range("D48") = Range("D48") - Range("D" & Target.Row) Range("G48") = Range("G48") - Range("G" & Target.Row) End Sub Posting an actual worksheet would likely get better solutions. |
#2
|
||||
|
||||
![]() Quote:
@paulie Please wrap code with code tags. It makes the thread easier to read and the code easier to copy To do this edit your post, click " go advanced", enter your post - select the code and click the #button Thanks
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Auto fill drops down using VBA code based on selection | AgilityJS | Word VBA | 5 | 11-03-2015 07:50 PM |
![]() |
trainsy | Word | 2 | 06-04-2014 04:43 AM |
![]() |
Ulodesk | Word VBA | 4 | 06-19-2012 06:09 AM |
![]() |
Antfield | PowerPoint | 3 | 05-27-2012 11:21 AM |
![]() |
chesspupil | Word VBA | 7 | 05-09-2010 05:43 AM |