PDA

View Full Version : Refer to a cell in another worksheet (macro)



SaxumHS
02-26-2018, 02:48 AM
Hi there,


I want to hide certain rows, depending on a certain cell value of a different worksheet.
The macro works (attachment 1), as long as I target a cell on the same worksheet as the hidden/unhidden rows.
However, when I try to target a cell on a different worksheet ("Projectgegevens"), nothing happens.. (attachment 2)

Below you can see the change between the codes.
Anyone got an idea to get this working?

2169821699

Thanks in advance!

SaxumHS
02-26-2018, 03:14 AM
It appears the code works after all, you just need to modify a cell in order for the macro to run.
Is there a way to let it run automatically if the target range changes? Just like it did in 'attachment 1'

Paul_Hossler
02-26-2018, 03:49 PM
In ThisWorkbook module (not a single sheet module) use the



Option Explicit

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name = "Projectgegevens" Then
etc.



End Sub