Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default how to auto expand linked data from another cell?

Hi,

Although this code works with cells where data is actually in it, I need it to work where the cell contains text that has been linked from another sheet.

Can anyone help?

thanks



donna-LexusWebs wrote:

I added the VBA to an existing worksheet and although it did not expand myrows
18-Mar-10

I added the VBA to an existing worksheet and although it did not expand my
rows as soon as I added the code, as soon as I typed into the cell again the
row expanded and stayed expanded. I hope that helps!

Thanks for the code - and the specific instructions where to add it (rt-clk
on the tab). I never knew that and always wondered how code was being added!!

Thanks again!

"Gord Dibben" wrote:

Previous Posts In This Thread:

On Thursday, February 22, 2007 1:49 PM
Caro wrote:

Autosize cells as data is entered
Hello.

I have my cells set to Wrap & the row is set to Auto-Fit. The "Number" is
set to General.

When I add text, it wraps, however, the cell-size is not changing! What do
I have to do to get the cell (or row height) to grow as text is added?

--
Carol

On Thursday, February 22, 2007 2:30 PM
Gord Dibben wrote:

I'm betting you have some "merged cells" which won't Autofit without VBA code.
I am betting you have some "merged cells" which will not Autofit without VBA code.

If this is the case and you are interested in the code, post back.


Gord Dibben MS Excel MVP

wrote:

On Thursday, February 22, 2007 2:38 PM
Caro wrote:

Nevermind!
Nevermind! Just realized my cells are merged - therefore, none of the
solutions I was trying will work.
--
Carol


"Carol" wrote:

On Thursday, February 22, 2007 2:42 PM
Caro wrote:

It is the case!
It is the case! I think we were both responding to my post at the same
time.. I would love the VBA code - though a novice at that. HOWEVER - if
it's easier than completely re-doing my form, I'll be happy to take a stab at
it!

Thank you Gord!
--
Carol


"Gord Dibben" wrote:

On Thursday, February 22, 2007 3:05 PM
Gord Dibben wrote:

I avoid meged cells like the plague simply due to the many problems caused
I avoid meged cells like the plague simply due to the many problems caused by
these.

But............................

Here is event code from Greg Wilson.

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

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
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
Application.ScreenUpdating = True
End If
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the above into that sheet module.

As you enter data the rows will autofit.


Gord

On Thu, 22 Feb 2007 11:42:45 -0800, Carol
wrote:

On Thursday, February 22, 2007 4:50 PM
Caro wrote:

You (and Greg Wilson)...... BRILLIANT! Worked beautifully!
You (and Greg Wilson)...... BRILLIANT! Worked beautifully!

Thank you for help - and perfect instruction!
--
Carol


"Gord Dibben" wrote:

On Wednesday, October 15, 2008 7:35 PM
Bria wrote:

Does anyone know how to modify this code so that it will work in a protected
Does anyone know how to modify this code so that it will work in a protected
sheet?

"Gord Dibben" wrote:

On Wednesday, October 15, 2008 10:33 PM
Gord Dibben wrote:

Private Sub Worksheet_Change(ByVal Target As Range)Dim NewRwHt As SingleDim
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
On Error GoTo endit
Application.EnableEvents = False
With Target
If .MergeCells And .WrapText Then
ActiveSheet.Unprotect Password:="justme"
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
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
Application.ScreenUpdating = True
End If
End With
endit:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme"
End Sub


Gord

On Wed, 15 Oct 2008 16:35:03 -0700, Brian
wrote:

On Thursday, October 16, 2008 9:31 AM
Bria wrote:

Thank you, Gord!
Thank you, Gord!

Note that I did have a slight issue where the resized cells were becoming
locked after editing, but I stole a line of code (ma.Locked = False) from
another post, and that seems to solve the issue.

Thanks again.


"Gord Dibben" wrote:

On Thursday, October 16, 2008 12:37 PM
Gord Dibben wrote:

Autosize cells as data is entered
Good to hear

Thanks for the feedback

wrote:

On Monday, June 08, 2009 1:45 PM
brianna wrote:

will this work for data that has already been entered into my sheet or will
will this work for data that has already been entered into my sheet or will
this only work on a new sheet and any data entered after it is applied?

"Gord Dibben" wrote:

On Monday, June 08, 2009 11:59 PM
Gord Dibben wrote:

Only works when entering new data or editing existing data.
Only works when entering new data or editing existing data.


Gord

On Thursday, March 18, 2010 11:50 AM
donna-LexusWebs wrote:

I added the VBA to an existing worksheet and although it did not expand myrows
I added the VBA to an existing worksheet and although it did not expand my
rows as soon as I added the code, as soon as I typed into the cell again the
row expanded and stayed expanded. I hope that helps!

Thanks for the code - and the specific instructions where to add it (rt-clk
on the tab). I never knew that and always wondered how code was being added!!

Thanks again!

"Gord Dibben" wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Report Engine, Part 1
http://www.eggheadcafe.com/tutorials...ne-part-1.aspx
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
formulae to look at 52 sheets &count if 2 cells have data entered bsnapool Excel Discussion (Misc queries) 1 July 10th 06 04:55 PM
Unhide cells when data is entered greyo Excel Worksheet Functions 0 August 8th 05 07:39 PM
Protect data in cells after entered Jeff Hall Excel Discussion (Misc queries) 1 May 16th 05 08:54 PM
How to only print cells where there is data entered, as in a sched Cel Excel Discussion (Misc queries) 1 April 19th 05 10:43 PM
How do I automatically shade cells depending on data entered? Jim Johnson Excel Worksheet Functions 6 October 29th 04 07:01 PM


All times are GMT +1. The time now is 09:57 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"