Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe Joe is offline
external usenet poster
 
Posts: 476
Default Autofit code Issue

Is there any reason why the following code would work fine in excel 2003 but
not in 2000? The code is to get around the autofit issue with merged cells.

Thanks very much,

Joe

Dim OldRng As Range ' DECLARED THIS AT TOP OF MODULE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range
Dim Protected As Boolean

If Target.Column = 1 And (Target.Row 16 And Target.Row < 42) Then
Cells(Target.Row, 2).Select
End If
Protected = False
Set c = Cells(Target.Row, 1)
If OldRng Is Nothing Then Set OldRng = c
If Not Intersect(OldRng, c) Is Nothing Then
Application.ScreenUpdating = True
If Me.ProtectContents Then
Protected = True
Me.Unprotect
End If
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
ma.Locked = False
If Protected Then Me.Protect
Application.ScreenUpdating = True
End If
Set OldRng = Target
Set c = Nothing
Set OldRng = Nothing
End Sub
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
Issue w/ Autofit Row Heights bbddvv Excel Discussion (Misc queries) 12 September 29th 06 03:35 PM
AutoFit rows issue stego Excel Discussion (Misc queries) 0 February 28th 06 09:39 PM
Autofit Column Headers with wrapped text (Not a merged cell issue) Mark Excel Programming 0 September 13th 05 12:42 AM
autofit row code Randy Starkey Excel Programming 7 March 25th 05 11:58 AM
Need code to Autofit Row Height on recalculation Bob Tarburton Excel Discussion (Misc queries) 0 March 4th 05 08:31 PM


All times are GMT +1. The time now is 12:09 PM.

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

About Us

"It's about Microsoft Excel"