+ Reply to Thread
Results 1 to 2 of 2

Autofit Pivot column by Criteria

  1. #1
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Autofit Pivot column by Criteria

    Hi all,

    I'm looking to see if I can do a search on a pivot table for the word "Total" which is in row 4 and then adjust the column width for each cell it finds to 2.5

    I've recorded the below which works if you use ctrl A to select all but when i run the macro it changes all the column widths to 2.5

    Any thoughts ??


    VBA:
    Sub Autofit()

    Cells.EntireColumn.Autofit
    Rows("4:4").Select
    Selection.Find(What:="total", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    Selection.ColumnWidth = 2.5
    End Sub


    Thanks in advance

    VBA Noob

  2. #2
    excelent
    Guest

    RE: Autofit Pivot column by Criteria

    Hi Noob try this instead
    Range("a:a").Columns.AutoFit ' for column a, chage to yours


    "VBA Noob" skrev:

    >
    > Hi all,
    >
    > I'm looking to see if I can do a search on a pivot table for the word
    > "Total" which is in row 4 and then adjust the column width for each
    > cell it finds to 2.5
    >
    > I've recorded the below which works if you use ctrl A to select all but
    > when i run the macro it changes all the column widths to 2.5
    >
    > Any thoughts ??
    >
    >
    > VBA:
    > Sub Autofit()
    >
    > Cells.EntireColumn.Autofit
    > Rows("4:4").Select
    > Selection.Find(What:="total", After:=ActiveCell,
    > LookIn:=xlFormulas, _
    > LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    > MatchCase:=False, SearchFormat:=False).Activate
    > Selection.ColumnWidth = 2.5
    > End Sub
    >
    >
    > Thanks in advance
    >
    > VBA Noob
    >
    >
    > --
    > VBA Noob
    > ------------------------------------------------------------------------
    > VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
    > View this thread: http://www.excelforum.com/showthread...hreadid=536587
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1