When to use hide/unhide vs visible = true/false

IdkWhatImDoing

New Member
Joined
Dec 29, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I've written a handful of VBA and I always get caught up on when to use certain terminology, more specifically when it comes to hiding/unhiding.
I've found that sometimes the correct method is to use

something.visible = true / something.visible = false

and other times I have to write

something.unhide / something.hide

is there a rule that let's me know when to use which? I've found that they are not interchangeable.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi @IdkWhatImDoing. Thanks for posting on the forum.

We use the property that the object corresponds to.

I don't remember at this moment which object has the 2 properties Hide/Unhide and Visible and that the functionality is the same. If you help us with an example.

But if that were the case, there is no rule to use either of the 2. I also don't see which one is better than the other.
The recommendation is that you use the one you prefer, the one that is easier for you to remember.

For example, the following options do the same thing and there is no advantage of one option over the other.
VBA Code:
Sub test3()
  Range("B3").Font.Bold = True
End Sub
VBA Code:
Sub test4()
  Range("B3").Font.FontStyle = "Bold"
End Sub
I use the first one, it is the one that I remember immediately.

--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------
 
Upvote 0
As Dante has stated in practice it makes no difference to the end result, it is just hide is a method and visible is a property.
If you use hide on a userform for example and look at the forms properties you'll see that the visible property has been set to False.
 
Upvote 1

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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