Consulting

Results 1 to 8 of 8

Thread: First unhidden column

  1. #1

    First unhidden column

    Instead of setting the code to column "A", how can I set it to the first unhidden column from the left? Example if column A is hidden, then set column B or C etc. Thanks

    For Each c In Range("A1", Range("A" & Rows.Count).End(xlUp))

  2. #2
    Any help on this request?

  3. #3
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    If you know row1 is visible:
    [vba]Rows(1).Specialcells(xlcelltypevisible)(1).Column[/vba]
    Be as you wish to seem

  4. #4
    try like
    for each col in columns
       if not col.hidden then exit for
    next
    For Each c In Range(cells(1, 1), cells(rows.count, col.column)).End(xlUp)


  5. #5
    Aflatoon...forgive me, but how do I apply it to my code?

    westconn1, it seems to not accomplish the task. here's the code I'm using...

    For Each c In Range("A1", Range("A1" & Rows.Count).End(xlUp))
        Select Case c
            Case "AL"
                c = "Alabama"
            Case "AZ"
                c = "Arizona"
        End select
    next c
    BTW, Column 1 is hidden, but I don't want to hard code column 1 because, the format could change to column 1 & 2 or 1,2, & 3, etc
    Last edited by av8tordude; 02-06-2014 at 05:07 AM.

  6. #6
    still seeking help. Thanks for your assistances.

  7. #7
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Like this:
    [vba]Dim lCol as Long
    lCol = Rows(1).Specialcells(xlcelltypevisible)(1).Column
    For Each c In Range("A" & lcol, Cells(Rows.Count, lCol).End(xlUp)).Cells
    Select Case c.Value
    Case "AL"
    c.Value = "Alabama"
    Case "AZ"
    c.Value = "Arizona"
    End Select
    Next c[/vba]
    Be as you wish to seem

  8. #8
    Works perfect Aflatoon. Thank you! :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •