Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:01:45+00:00 2026-06-15T17:01:45+00:00

I have a bunch of workbooks with specific strings in the first row. So,

  • 0

I have a bunch of workbooks with specific strings in the first row. So, for example I, say I have “Dog”, “Cat”, “Squirrel”, and “Fish” in rows A – D. I would like to have a macro that searches for the values ‘Dog’ and ‘Squirrel’, and hide the columns, and then subsequently set the width of “Cat” and “Fish” to a value of 11.

I cannot just use column numbers because they are not consistent across all my workbooks. Thanks for your help.

Sub HideColumn1()
If Range("B4").Value = 0 Then
    Columns("H").EntireColumn.Hidden = True
Else
    Columns("H").EntireColumn.Hidden = False
End If
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:01:49+00:00Added an answer on June 15, 2026 at 5:01 pm

    Change Range(“A1:D1”) to your desired range or something more dynamic:

    Dim cell As Range
    Dim hiddenRng As Range, widthRng As Range
    
    For Each cell In Range("A1:D1")
    
        If cell = "Dog" Or cell = "Squirrel" Then
    
            If (hiddenRng Is Nothing) Then
                Set hiddenRng = cell
            Else
                Set hiddenRng = Union(hiddenRng, cell)
            End If
    
        End If
    
        If cell = "Cat" Or cell = "Fish" Then
    
            If (widthRng Is Nothing) Then
                Set widthRng = cell
            Else
                Set widthRng = Union(widthRng, cell)
            End If
    
        End If
    
    Next cell
    
    If (Not hiddenRng Is Nothing) Then hiddenRng.EntireColumn.Hidden = True
    If (Not widthRng Is Nothing) Then widthRng.EntireColumn.ColumnWidth = 11
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have bunch of strings, some of which are fairly long, like so: movie.titles
I have a bunch of strings that are dependent on static dictionaries and each
lets say I have bunch of hyperlinks. When link is clicked, I'd like an
Let's say we have bunch of artefacts, all of which have a child/transitive dependency
For example I have bunch of functions like these: function a() { //do something
i have bunch of rows containing http://www.domainname.com i need to update those so http://
i have bunch of dirs , say **a, b, c0, d, Z , foo,
I have bunch of images (say 10) I have generated both as array or
I have bunch of default strings and ints throughout the app. like default names,
I have bunch of php files in directory structure say /mylibs I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.