Share via

Conditional Format: Need to set column width based on if $A$1 is blank

Anonymous
2022-05-16T02:13:41+00:00

Hi,

I have a spreadsheet with lots of columns that only need displayed if something is wrong. I Have not been able to find a way to set a selection of columns width programicaly, or to hide/unhide them Please help!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2022-05-17T01:48:23+00:00

    May I know any details why it doesn't worked on your side?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-05-16T06:26:03+00:00

    Hi Jeffrey, hope you're doing well. I’m Ian, and I’m happy to help you today.

    You can do this via VBA Macro. Please sample code below. You can change the column and width of it.

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("A1")) Is Nothing Then
            If IsEmpty(Range("A1").Value) Then
                Columns("B").ColumnWidth = 5
            Else
                Columns("B").ColumnWidth = 10
            End If
        End If
    End Sub
    

    This is a user-to-user support forum and I am a fellow user.

    I hope this helps, but please let me know if you need anything else.

    Was this answer helpful?

    0 comments No comments