View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
malik641[_20_] malik641[_20_] is offline
external usenet poster
 
Posts: 1
Default newbie VBA help please


Okay, this works.
Try this:

Make sure you keep the

PRIVATE SUB WORKSHEET_CHANGE(BYVAL TARGET AS RANGE)
AUTOFITMERGEDCELLROWHEIGHT
END SU

That Jim and Steve told you to change.

and in your *Sub AutoFitMergedCellRowHeight () * macro right above th
first if statement add:

ACTIVECELL.OFFSET(-1, 0).SELECT[/b]

AND HERE IS WHAT YOU END UP WITH.



SUB AUTOFITMERGEDCELLROWHEIGHT()

DIM CURRENTROWHEIGHT AS SINGLE, MERGEDCELLRGWIDTH AS SINGLE
DIM CURRCELL AS RANGE
DIM ACTIVECELLWIDTH AS SINGLE, POSSNEWROWHEIGHT AS SINGLE

[b]ACTIVECELL.OFFSET(-1, 0).SELEC

If ActiveCell.MergeCells Then
With ActiveCell.MergeArea
If .Rows.Count = 1 And .WrapText = True Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
ActiveCellWidth = ActiveCell.ColumnWidth
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth + MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight PossNewRowHeight, _
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If

End Sub

PRIVATE SUB WORKSHEET_CHANGE(BYVAL TARGET AS RANGE)
AUTOFITMERGEDCELLROWHEIGHT
END SU
---------------------------------------------------

Now after you enter the text and you press enter it will change it fo
you automatically and remain to be the cell that you entered the tex
in.

Hope this is what you were looking for

--
malik64

-----------------------------------------------------------------------
malik641's Profile: http://www.excelforum.com/member.php...fo&userid=2419
View this thread: http://www.excelforum.com/showthread.php?threadid=38855