Worksheet_Change by calculated value?

austin350s10

Active Member
Joined
Jul 30, 2010
Messages
321
I am working on a sheet that needs to run a script when specified range changes it's calculated value.

I tried using the Worksheet_Change event but the problem is that the range I am monitoring contains only calculated values not real values. When the script I have now runs it sees that the cells in the range have not changed because it is looking at the formula in the cell. Is there a way to check the calculated value instead of the formula?


Code Now:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Range1 As Range
Set Range1 = Range("A3:A10")
If Not Intersect(Target, Range1) Is Nothing Then
For Each wks In ThisWorkbook.Worksheets(Array("Blood Sugar Log", "Blood Pressure Log", "Respiration Log", "Pulse Log", "Weight Log", "Temperature Log", "Medication Log", "Blood Sugar Log", "Blood Sugar Log Plus"))
            wks.Visible = xlSheetVeryHidden
        Next wks
For Each c In Range1
Dim L1 As String
    If c <> "- Pick Log Sheet -" Then
        For Each wks In ThisWorkbook.Worksheets(Array("Blood Sugar Log", "Blood Pressure Log", "Respiration Log", "Pulse Log", "Weight Log", "Temperature Log", "Medication Log", "Blood Sugar Log", "Blood Sugar Log Plus"))
            L1 = wks.Name
                If c = L1 Then
                    wks.Visible = xlSheetVisible
                End If
        Next wks
    End If
Next c
End If
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Each cell contains a formula that refers to a cell on a different sheet. Below is one of the formulas:

Code:
='Inital Needs Assessment Final 12-2010.xlsm'!LogA
 
Upvote 0
I know it kinda sloppy...well really sloppy. I think I know how to clean in up but it doesn't seem to work for me.

I inserted the code below into the worksheet where the real values are actually changing but when it reaches the first For Each loop it doesn't seem to like the variable wks. Any ideas?


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Range6 As Range
Set Range6 = Range("LogA, LogB, LogC, LogD, LogE, LogF, LogG, LogI")
If Not Intersect(Target, Range6) Is Nothing Then
For Each wks In ThisWorkbook.Worksheets(Array("Blood Sugar Log", "Blood Pressure Log", "Respiration Log", "Pulse Log", "Weight Log", "Temperature Log", "Medication Log", "Blood Sugar Log", "Blood Sugar Log Plus"))
            wks.Visible = xlSheetVeryHidden
        Next wks
For Each c In Range6
Dim L1 As String
    If c <> "- Pick Log Sheet -" Then
        For Each wks In ThisWorkbook.Worksheets(Array("Blood Sugar Log", "Blood Pressure Log", "Respiration Log", "Pulse Log", "Weight Log", "Temperature Log", "Medication Log", "Blood Sugar Log", "Blood Sugar Log Plus"))
            L1 = wks.Name
                If c = L1 Then
                    wks.Visible = xlSheetVisible
                End If
        Next wks
    End If
Next c
End If
End Sub
 
Upvote 0
I just tried changing it to just:

Code:
For Each [COLOR=Red]wks [/COLOR]In Worksheets(Array("Blood Sugar Log", "Blood Pressure Log", "Respiration Log", "Pulse Log", "Weight Log", "Temperature Log", "Medication Log", "Blood Sugar Log", "Blood Sugar Log Plus"))

When it gets to wks I receive the following compile error:

Variable not defined

Weird?
 
Upvote 0
Better declare it with a Dim statement then (I expect you have Option Explicit at the top of the module).

You are going to have to qualify the worksheets with the name of the workbook. Otherwise the ActiveWorkbook will be used.
 
Upvote 0
That was it. It got way farther in the code this time. It needs one last tweak and I think it will work fine. When it gets to the following line:
Code:
L1 = wks[COLOR=Red].Name[/COLOR]
I receive the following compile error:

Method or data member not found

Why would it do that?

Thanks for all your help. Sorry if I'm bugging you though.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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