PC Review


Reply
Thread Tools Rate Thread

Column Autofit

 
 
=?Utf-8?B?S2FyZW4gTWNLZW56aWU=?=
Guest
Posts: n/a
 
      23rd Apr 2007
I am using the code below to autofit the columns on my spreadsheet.

Private Sub Worksheet_Change(ByVal Target As Range)

Me.Application.ActiveWorkbook.RefreshAll
Target.EntireColumn.AutoFit
End Sub

This works fine normally but I have 13 columns on this spreadsheet that
contain Hyperion Retrieve Formula. The values in these columns update when
either D66 or D68 are changed but the column wide is not updating with this.
I end up with the columns either too wide where the value has reduced, or
filled with #### where the number of digits has increased.

Any suggestions how I can resolve this? Help with the code would be great as
I'm just finding my feet with VBA.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      23rd Apr 2007
Karen,

Try:


Private Sub Worksheet_Change(ByVal Target As Range)
Me.Application.ActiveWorkbook.RefreshAll
Target.EntireColumn.AutoFit

On Error Resume Next
Target.Dependents.EntireColumn.AutoFit
End Sub

--
Hope that helps.

Vergel Adriano


"Karen McKenzie" wrote:

> I am using the code below to autofit the columns on my spreadsheet.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Me.Application.ActiveWorkbook.RefreshAll
> Target.EntireColumn.AutoFit
> End Sub
>
> This works fine normally but I have 13 columns on this spreadsheet that
> contain Hyperion Retrieve Formula. The values in these columns update when
> either D66 or D68 are changed but the column wide is not updating with this.
> I end up with the columns either too wide where the value has reduced, or
> filled with #### where the number of digits has increased.
>
> Any suggestions how I can resolve this? Help with the code would be great as
> I'm just finding my feet with VBA.

 
Reply With Quote
 
=?Utf-8?B?S2FyZW4gTWNLZW56aWU=?=
Guest
Posts: n/a
 
      23rd Apr 2007
That works brilliantly!

Thanks for your help

"Vergel Adriano" wrote:

> Karen,
>
> Try:
>
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Me.Application.ActiveWorkbook.RefreshAll
> Target.EntireColumn.AutoFit
>
> On Error Resume Next
> Target.Dependents.EntireColumn.AutoFit
> End Sub
>
> --
> Hope that helps.
>
> Vergel Adriano
>
>
> "Karen McKenzie" wrote:
>
> > I am using the code below to autofit the columns on my spreadsheet.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> >
> > Me.Application.ActiveWorkbook.RefreshAll
> > Target.EntireColumn.AutoFit
> > End Sub
> >
> > This works fine normally but I have 13 columns on this spreadsheet that
> > contain Hyperion Retrieve Formula. The values in these columns update when
> > either D66 or D68 are changed but the column wide is not updating with this.
> > I end up with the columns either too wide where the value has reduced, or
> > filled with #### where the number of digits has increased.
> >
> > Any suggestions how I can resolve this? Help with the code would be great as
> > I'm just finding my feet with VBA.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofit column Help? Tim Microsoft Excel Programming 5 8th Jan 2010 07:16 AM
Column Autofit mcolson Microsoft Excel Misc 2 6th Mar 2008 10:19 PM
Column AutoFit C API Siva Microsoft Excel Programming 1 8th Jan 2008 04:41 PM
how to autofit column widths =?Utf-8?B?YnJldzJ1?= Microsoft Excel New Users 1 31st Oct 2007 11:21 AM
Column AutoFit diego Microsoft Excel Misc 0 18th Sep 2003 06:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:37 AM.