VBA to update/reformat cells on summary sheet when another sheet changes

Drisso in Vegas

New Member
Joined
Aug 23, 2018
Messages
6
Hi there,
I have a workbook that tracks projects by project# (CIR). A button runs a VBA module for NewProjects that prompts for a new (unique number) CIR, copies and pastes a new row into the "Project Summary" sheet, and copies a project details sheet from a template sheet and names it as CIR. So there are multiple "CIR" sheets with the same certain fields that show on the one "Project Summary" sheet. This is done with =INDIRECT formulas in the copied rows of the "Project Summary" sheet like =INDIRECT("'"&$A2&"'!C1").
The problem comes when I update fields in the project details sheets that change from numbers to dates (or vise versa) because the "Project Summary" fields need to be reformatted to or from DATE. I need VBA to update (and reformat) cells in "Project Summary" when the corresponding cells in the "CIR" sheets are changed. It seems like it should be simple but I can't think of the best way ( Do While Loop to find cells by CIR in "Project Summary", Find function, Autofilter?). Can someone point me in the right direction? Thanks.

PROJECT SUMMARY
[TABLE="width: 100, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CIR[/TD]
[TD]DUE DATE
[/TD]
[TD]TASK1[/TD]
[TD]TASK2[/TD]
[TD]TASK3[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]11111
[/TD]
[TD]1/15/2019[/TD]
[TD]5/15/2018[/TD]
[TD]83[/TD]
[TD]7/30/18[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]22222[/TD]
[TD]2/15/2019[/TD]
[TD]39[/TD]
[TD]8/5/2018[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]33333[/TD]
[TD]3/1/2019[/TD]
[TD]40[/TD]
[TD]8/1/2018[/TD]
[TD]8/6/2018[/TD]
[/TR]
</tbody>[/TABLE]









11111 (PROJECT DETAILS)
[TABLE="width: 200"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CIR[/TD]
[TD]
[TABLE="width: 200"]
<tbody>[TR]
[TD]11111[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD]DATE SENT[/TD]
[TD]DAYS-PENDING[/TD]
[TD]DATE-REC'D[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]DUE DATE[/TD]
[TD]
[TABLE="width: 200"]
<tbody>[TR]
[TD]1/15/2019[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD]TASK1[/TD]
[TD]5/1/18[/TD]
[TD]14[/TD]
[TD]5/15/18[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]TASK2[/TD]
[TD]6/1/18[/TD]
[TD]83[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]TASK3[/TD]
[TD]7/5/18[/TD]
[TD]25[/TD]
[TD]7/30/18[/TD]
[/TR]
</tbody>[/TABLE]

****** id="cke_pastebin" style="position: absolute; top: 399px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">[TABLE="width: 200"]
<tbody>[TR]
[TD]11111[/TD]
[/TR]
</tbody>[/TABLE]
</body>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Ok so I came up with this Do Until Loop that gets "Project Summary" C2 updated when the date in "Project Details" F2 changes and places the number (14 from G2) in "Project Summary" C2 (sorry, I think the tables above are a little off).

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cir As String
Dim task1 As Integer
If Target.Address = "$F$2" Then
Cir = ActiveSheet.Range("C1").Value
task1 = ActiveSheet.Range("G2").Value
Worksheets("Project Summary").Activate
Worksheets("Project Summary").Range("A2").Select
Do Until ActiveCell.Value = Cir
ActiveCell.Offset(1, 0).Select
Loop
If Worksheets(Cir).Range("F2") = "" Then Exit Sub
ActiveCell.Offset(0, 2).Select
ActiveCell.NumberFormat = "0"
ActiveCell = task1
End If
End Sub



The problem now is "Project Summary" C2 only changes when "Project Details" F2 changes, but G2 has a formula =IF(F2,IF(H2,H2-F2,TODAY()-F2),0) that increments daily. When the workbook is opened the next day, G2 has incremented but C2 has not. Is there a different Event Procedure to make this happen? I'm getting the feeling I might have designed this backwards, by pushing the data from the "Project Details" sheets. Maybe the "Project Summary" sheet should be "pulling" the date from the other sheets? Thoughts? Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,215
Members
453,024
Latest member
Wingit77

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