Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Column Autofit

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Column Autofit

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Column Autofit

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column Autofit mcolson Excel Discussion (Misc queries) 2 March 6th 08 10:19 PM
how to autofit column widths brew2u New Users to Excel 1 October 31st 07 11:21 AM
Excel column autofit J. M. De Moor Excel Programming 3 January 6th 07 09:49 PM
Autofit doesn't work when column not enough width Alex St-Pierre Excel Programming 3 April 19th 06 07:35 PM
Column Autofit Problem Graham Haughs Excel Programming 7 August 9th 04 02:25 PM


All times are GMT +1. The time now is 07:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"