+ Reply to Thread
Results 1 to 5 of 5

Using Code to Adjust Specific Column Width

  1. #1
    Nigel Bennett
    Guest

    Using Code to Adjust Specific Column Width

    I have a spreadsheet that retrieves data after it has
    retreived the data I want to use code to look in row 5 and
    go thru each cell up to the last colum, if there is
    nothing in the cell I want it to resize it to a smaller
    size,

    is there anyway of doing this

    Thanks



  2. #2
    Bob Phillips
    Guest

    Re: Using Code to Adjust Specific Column Width


    If Application.COUNTA(Range("C:C") = 0 Then
    Range("C:C").ColumnWidth = 5
    End If

    --
    HTH

    Bob Phillips

    "Nigel Bennett" <[email protected]> wrote in message
    news:[email protected]...
    > I have a spreadsheet that retrieves data after it has
    > retreived the data I want to use code to look in row 5 and
    > go thru each cell up to the last colum, if there is
    > nothing in the cell I want it to resize it to a smaller
    > size,
    >
    > is there anyway of doing this
    >
    > Thanks
    >
    >




  3. #3
    Nigel Bennett
    Guest

    Re: Using Code to Adjust Specific Column Width

    Could you explain the range definition for me please
    >-----Original Message-----
    >
    > If Application.COUNTA(Range("C:C") = 0 Then
    > Range("C:C").ColumnWidth = 5
    > End If
    >
    >--
    > HTH
    >
    >Bob Phillips
    >
    >"Nigel Bennett" <[email protected]> wrote in message
    >news:[email protected]...
    >> I have a spreadsheet that retrieves data after it has
    >> retreived the data I want to use code to look in row 5

    and
    >> go thru each cell up to the last colum, if there is
    >> nothing in the cell I want it to resize it to a smaller
    >> size,
    >>
    >> is there anyway of doing this
    >>
    >> Thanks



  4. #4
    Nigel Bennett
    Guest

    Re: Using Code to Adjust Specific Column Width


    No the code didn't work I had the following entered

    If application.CountA(range("A5,CG5")) = 0 Then
    range("A5,CG5").ColumnWidth = 5
    End If

    any help


    >-----Original Message-----
    >
    > If Application.COUNTA(Range("C:C") = 0 Then
    > Range("C:C").ColumnWidth = 5
    > End If
    >
    >--
    > HTH
    >
    >Bob Phillips
    >
    >"Nigel Bennett" <[email protected]> wrote in message
    >news:[email protected]...
    >> I have a spreadsheet that retrieves data after it has
    >> retreived the data I want to use code to look in row 5

    and
    >> go thru each cell up to the last colum, if there is
    >> nothing in the cell I want it to resize it to a smaller
    >> size,
    >>
    >> is there anyway of doing this
    >>
    >> Thanks
    >>
    >>

    >
    >
    >.
    >


  5. #5
    gocush
    Guest

    RE: Using Code to Adjust Specific Column Width

    How about the following:


    Dim Rng As Range
    Dim oCell As Range
    Dim LastCol As Range

    Set LastCol = Cells(5, Columns.Count).End(xlToLeft)
    Set Rng = Range(Cells(5, 1), LastCol)

    For each oCell in Rng
    If oCell="" then oCell.ColumnWidth=5
    Next oCell


    "Nigel Bennett" wrote:

    > I have a spreadsheet that retrieves data after it has
    > retreived the data I want to use code to look in row 5 and
    > go thru each cell up to the last colum, if there is
    > nothing in the cell I want it to resize it to a smaller
    > size,
    >
    > is there anyway of doing this
    >
    > Thanks
    >
    >
    >


+ 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