Having trouble hiding activecell column across tabs using vba

0 votes

The activecell column across the first four tabs has to be hidden. It appears that the vba below is not functioning. Only the activecell on the first tab of the activesheet is hidden. In essence, I choose to focus the first four tabs, choose cell A1, and then use the code below:

ActiveCell.EntireColumn.Hidden = True

This only conceals Column A on Tab 1, not in Tabs 2, 3, or 4. Could someone kindly assist in getting the right code? As a reminder, it must be the selected cell and not the Range ("A1"). EntireColumn. Because I'm trying to hide a cell using an offset function, cell can be any active cell, hence Hidden = True. We appreciate any assistance.

Feb 9, 2023 in Others by Kithuzzz
• 38,020 points
545 views

1 answer to this question.

0 votes

You might keep track of the location of the active cell, cycle over each worksheet, and base your column hiding on that location.

Sub tested()

    Dim cell_address As String
    Dim wsName, ws, c As Range
    
    cell_address = ActiveCell.Address
    
    wsName = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
    
    For Each ws In wsName
        Sheets(ws).Range(cell_address).EntireColumn.Hidden = True
    Next

End Sub
answered Feb 9, 2023 by narikkadan
• 63,720 points

Related Questions In Others

0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
976 views
0 votes
1 answer
0 votes
1 answer

VBA excel - create skype account using powershell script

Although the PowerShell portion has not been ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,720 points
614 views
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,720 points
1,211 views
0 votes
1 answer

Excel How to programmatically hide columns while keeping navigation buttons in view at top

Obviously, this does not help with the ...READ MORE

answered Nov 8, 2022 in Others by narikkadan
• 63,720 points
779 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,079 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,495 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
803 views
0 votes
1 answer

Highlight active row/column in Excel without using VBA?

Create two formula-based rules: =ROW()=CELL("row") =COLUMN( ...READ MORE

answered Oct 27, 2022 in Others by narikkadan
• 63,720 points
2,887 views
0 votes
1 answer

Runtime error 438 while importing data in excel from secured website using VBA

Replace With ieDoc.forms(0) .userType.Value = "1" ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,720 points
840 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP