Column hidden call macro / column visible call macro

MarkReddell

Board Regular
Joined
Sep 1, 2011
Messages
210
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I'm needing to call a macro based on hidden or visible column C ??? :confused:
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Maybe something like this which goes into a worksheet event module for the worksheet with the hidden/unhidden col C. Each time the worksheet tab is clicked to activate the worksheet, the code will run automatically.
Code:
Private Sub Worksheet_Activate()
If Me.Columns("C").Hidden = False Then
    Call mySub1
Else
    Call mySub2
End If
End Sub
Sub mySub1()
'put your sub for col C not hidden here and remove the message box below
MsgBox "Hello - col C is not hidden"
End Sub
Sub mySub2()
'put your sub for col C hidden here and remove the message box below
MsgBox "Hello - col C is hidden"
End Sub
To install sheet code:
1. Right-click the worksheet tab you want to apply it to and choose 'View Code'. This will open the VBE window.
2. Copy the code below from your browser window and paste it into the white space in the VBE window.
3. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
4. Make sure you have enabled macros whenever you open the file or the code will not run.
 
Upvote 0
I'm needing to call a macro based on hidden or visible column C ??? :confused:

I'm using this macro currently.

Sub HdeDiscounts() Columns("C:C").Hidden = Not Columns("C:C").Hidden
End Sub

I need to be able to call AdjustRetail, or, ReadjustRetail. Is this possible???
 
Last edited:
Upvote 0
I'm using this macro currently.

Sub HdeDiscounts()
Columns("C:C").Hidden = Not Columns("C:C").Hidden
End Sub

I need to be able to call AdjustRetail, or, ReadjustRetail. Is this possible???
You are toggling the hidden property of the column. Which status (hidden or nonhidden) should result in a call to AdjustRetail?
 
Upvote 0
You are toggling the hidden property of the column. Which status (hidden or nonhidden) should result in a call to AdjustRetail?

Thanx for your help!!! Yes, when Col. C is hidden, Call Readjustretail, When Col. C is displayed, Call Adjustretail.
 
Upvote 0
Thanx for your help!!! Yes, when Col. C is hidden, Call Readjustretail, When Col. C is displayed, Call Adjustretail.
You haven't provided much info on what you want to accomplish so you may want to remove the col C hidden/unhidden toggle line from this.
Code:
Sub HdeDiscounts()
Columns("C:C").Hidden = Not Columns("C:C").Hidden
If Columns("C:C").Hidden Then
    Call Readjustretail
Else
    Call Adjustretail
End If
End Sub
 
Last edited:
Upvote 0
You haven't provided much info on what you want to accomplish so you may want to remove the col C hidden/unhidden toggle line from this.
Code:
Sub HdeDiscounts()
Columns("C:C").Hidden = Not Columns("C:C").Hidden
If Columns("C:C").Hidden Then
    Call Readjustretail
Else
    Call Adjustretail
End If
End Sub

Thank you very much! This Worx!!! Have a very blessed day!!!
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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