+ Reply to Thread
Results 1 to 5 of 5

Column Widths

  1. #1
    Pricklyflower
    Guest

    Column Widths

    Is there any way of being able to enter a number into a cell and that number
    will represent the width of the column? For example, if I wanted the cell to
    be a width of 5, I enter that number into a cell in the column?

    I hope I've explained that correctly, if not I'll try again!!

    Any help will be much appreciated.

    Many thanks.



  2. #2
    Nick Hodge
    Guest

    Re: Column Widths

    Only with code in say a worksheet_change event, a little like this (Works on
    Column A and a value in A1 (Little error checking contained)


    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo err:
    If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
    Application.EnableEvents = False
    Columns("A:A").ColumnWidth = Target.Value
    Application.EnableEvents = True
    End If
    err:
    Columns("A:A").ColumnWidth= 8.38
    Application.EnableEvents = True
    End Sub
    --
    HTH
    Nick Hodge
    Microsoft MVP - Excel
    Southampton, England
    www.nickhodge.co.uk
    nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS


    "Pricklyflower" <Pricklyflower@discussions.microsoft.com> wrote in message
    news:6F089985-EAB3-467C-BA8F-0D11CE82AB19@microsoft.com...
    > Is there any way of being able to enter a number into a cell and that
    > number
    > will represent the width of the column? For example, if I wanted the cell
    > to
    > be a width of 5, I enter that number into a cell in the column?
    >
    > I hope I've explained that correctly, if not I'll try again!!
    >
    > Any help will be much appreciated.
    >
    > Many thanks.
    >
    >




  3. #3
    Pricklyflower
    Guest

    Re: Column Widths

    Many thanks for this ... however I've never used code before - is this
    something that I can do easily or is it best left to the experts?

    "Nick Hodge" wrote:

    > Only with code in say a worksheet_change event, a little like this (Works on
    > Column A and a value in A1 (Little error checking contained)
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > On Error GoTo err:
    > If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
    > Application.EnableEvents = False
    > Columns("A:A").ColumnWidth = Target.Value
    > Application.EnableEvents = True
    > End If
    > err:
    > Columns("A:A").ColumnWidth= 8.38
    > Application.EnableEvents = True
    > End Sub
    > --
    > HTH
    > Nick Hodge
    > Microsoft MVP - Excel
    > Southampton, England
    > www.nickhodge.co.uk
    > nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS
    >
    >
    > "Pricklyflower" <Pricklyflower@discussions.microsoft.com> wrote in message
    > news:6F089985-EAB3-467C-BA8F-0D11CE82AB19@microsoft.com...
    > > Is there any way of being able to enter a number into a cell and that
    > > number
    > > will represent the width of the column? For example, if I wanted the cell
    > > to
    > > be a width of 5, I enter that number into a cell in the column?
    > >
    > > I hope I've explained that correctly, if not I'll try again!!
    > >
    > > Any help will be much appreciated.
    > >
    > > Many thanks.
    > >
    > >

    >
    >
    >


  4. #4
    Nick Hodge
    Guest

    Re: Column Widths

    It's up to you, it will work unaltered and you could start on the learning
    process or employ someone to do it for you

    You can right-click on a sheet tab and select view code, enter the code I
    gave you in the resulting window and the code will run on that sheet

    --
    HTH
    Nick Hodge
    Microsoft MVP - Excel
    Southampton, England
    www.nickhodge.co.uk
    nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS


    "Pricklyflower" <Pricklyflower@discussions.microsoft.com> wrote in message
    news:56E58F75-AF38-4AB6-BEED-DF071075DCDE@microsoft.com...
    > Many thanks for this ... however I've never used code before - is this
    > something that I can do easily or is it best left to the experts?
    >
    > "Nick Hodge" wrote:
    >
    >> Only with code in say a worksheet_change event, a little like this (Works
    >> on
    >> Column A and a value in A1 (Little error checking contained)
    >>
    >>
    >> Private Sub Worksheet_Change(ByVal Target As Range)
    >> On Error GoTo err:
    >> If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
    >> Application.EnableEvents = False
    >> Columns("A:A").ColumnWidth = Target.Value
    >> Application.EnableEvents = True
    >> End If
    >> err:
    >> Columns("A:A").ColumnWidth= 8.38
    >> Application.EnableEvents = True
    >> End Sub
    >> --
    >> HTH
    >> Nick Hodge
    >> Microsoft MVP - Excel
    >> Southampton, England
    >> www.nickhodge.co.uk
    >> nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS
    >>
    >>
    >> "Pricklyflower" <Pricklyflower@discussions.microsoft.com> wrote in
    >> message
    >> news:6F089985-EAB3-467C-BA8F-0D11CE82AB19@microsoft.com...
    >> > Is there any way of being able to enter a number into a cell and that
    >> > number
    >> > will represent the width of the column? For example, if I wanted the
    >> > cell
    >> > to
    >> > be a width of 5, I enter that number into a cell in the column?
    >> >
    >> > I hope I've explained that correctly, if not I'll try again!!
    >> >
    >> > Any help will be much appreciated.
    >> >
    >> > Many thanks.
    >> >
    >> >

    >>
    >>
    >>




  5. #5
    Pricklyflower
    Guest

    Re: Column Widths

    Many thanks Nick, I'll have a go at doing this tomorrow. Thanks ever so much
    for all your help, much appreciated.

    "Nick Hodge" wrote:

    > It's up to you, it will work unaltered and you could start on the learning
    > process or employ someone to do it for you
    >
    > You can right-click on a sheet tab and select view code, enter the code I
    > gave you in the resulting window and the code will run on that sheet
    >
    > --
    > HTH
    > Nick Hodge
    > Microsoft MVP - Excel
    > Southampton, England
    > www.nickhodge.co.uk
    > nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS
    >
    >
    > "Pricklyflower" <Pricklyflower@discussions.microsoft.com> wrote in message
    > news:56E58F75-AF38-4AB6-BEED-DF071075DCDE@microsoft.com...
    > > Many thanks for this ... however I've never used code before - is this
    > > something that I can do easily or is it best left to the experts?
    > >
    > > "Nick Hodge" wrote:
    > >
    > >> Only with code in say a worksheet_change event, a little like this (Works
    > >> on
    > >> Column A and a value in A1 (Little error checking contained)
    > >>
    > >>
    > >> Private Sub Worksheet_Change(ByVal Target As Range)
    > >> On Error GoTo err:
    > >> If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
    > >> Application.EnableEvents = False
    > >> Columns("A:A").ColumnWidth = Target.Value
    > >> Application.EnableEvents = True
    > >> End If
    > >> err:
    > >> Columns("A:A").ColumnWidth= 8.38
    > >> Application.EnableEvents = True
    > >> End Sub
    > >> --
    > >> HTH
    > >> Nick Hodge
    > >> Microsoft MVP - Excel
    > >> Southampton, England
    > >> www.nickhodge.co.uk
    > >> nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS
    > >>
    > >>
    > >> "Pricklyflower" <Pricklyflower@discussions.microsoft.com> wrote in
    > >> message
    > >> news:6F089985-EAB3-467C-BA8F-0D11CE82AB19@microsoft.com...
    > >> > Is there any way of being able to enter a number into a cell and that
    > >> > number
    > >> > will represent the width of the column? For example, if I wanted the
    > >> > cell
    > >> > to
    > >> > be a width of 5, I enter that number into a cell in the column?
    > >> >
    > >> > I hope I've explained that correctly, if not I'll try again!!
    > >> >
    > >> > Any help will be much appreciated.
    > >> >
    > >> > Many 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