Using VBA to check the value of a cell from another sheet to hide a row in another sheet?

zyntex

New Member
Joined
Aug 16, 2017
Messages
6
Hello,

I have a file with three sheets.

Table1, Table2 and Table3.

If the cell "C2" of "Table1" has a value cell "C2" of "Table2" will get it too via the formula "=Table1!C2"
Now I want that if cell "C2" of "Table2" has no value row "6" of "Table3" gets hidden.

I had it working within the same sheet with:
Code:
Sub Test()    
If Range("C2").Value = "" Then
Rows(6).Hidden = True
Else
Rows(6).Hidden = False
End If
End Sub

At the moment I have this code however I think I messed up the link between the sheets but can't help:
Code:
Sub Test()    
If Worksheets("Table2").Cells("C2").Value = "" Then
Worksheets("Table3").Rows("6").Hidden = True
Else
Worksheets("Table3").Rows("6").Hidden = False
End If
End Sub


Also are there any resources you can recommend to get into Excel VBA and especially stuff like the above?
 

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
Thank you. I want to use it as macro later on that's why I was writing a function. But your line doesn't work for me.

I see the issue as you've realised.

This should work as a one liner:

Code:
[COLOR=#333333]Worksheets("Table3").Rows(6).EntireRow.Hidden = val(Worksheets("Table2").Range("C2").Value )= 0[/COLOR]

Or as Fluff rightly pointed out:

Code:
[COLOR=#333333]Worksheets("Table3").Rows(6).EntireRow.Hidden = Worksheets("Table1").Range("C2").Value = ""[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,217,047
Messages
6,134,279
Members
449,863
Latest member
Snowmanx812

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