Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JLC JLC is offline
external usenet poster
 
Posts: 1
Default how do I create event-activated macros that check every cell?


I'm so thankful for Jim Rech's code* (and those who directed me to it)
that allows auto-expansion of merged cells, but I have a *shared
workbook *with at least *10 sheets*, each of which has more than *40
different merged cells *that may need auto-expansion. Because there are
so many merged cells, not to mention Excel-phobic users typing into
them, I want to avoid personally running this macro for each cell that
needs expansion. Unfortunately, my _very_ rudimentary VBA skills are of
no help.

Given that, I have several questions:


- Can I have the macro run automatically for each sheet, checking all
the merged cells (or simply all cells), when the user saves or exits?

- Can I have the macro check every single cell in the workbook? I'd
like to run this version manually.

- Can the macro activation event be when the user has finished
entering text and moves to a new cell whether by


- tabbing,
- hitting enter, or
- clicking on the next cell they want to modify?
If so, does anyone know how expensive this would be in terms of time
and memory? All my users are accessing the workbook remotely and
already have a good deal of lag due to outdated equipment.


*'Jim Rech's AutoFitMergedCellRowHeight Code'
(http://tinyurl.com/aknxy)


--
JLC
------------------------------------------------------------------------
JLC's Profile: http://www.excelforum.com/member.php...o&userid=28014
View this thread: http://www.excelforum.com/showthread...hreadid=488929

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how do I create event-activated macros that check every cell?

Is this any good for you

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = FalseSub AutoFitMergedCellRowHeight()
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
Dim cell As Range
Dim sh As Worksheet

If Target.MergeCells Then
With Target.MergeArea
If .Rows.Count = 1 And .Cells(1).WrapText = True Then
''<<.Cells(1) added
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
ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"JLC" wrote in message
...

I'm so thankful for Jim Rech's code* (and those who directed me to it)
that allows auto-expansion of merged cells, but I have a *shared
workbook *with at least *10 sheets*, each of which has more than *40
different merged cells *that may need auto-expansion. Because there are
so many merged cells, not to mention Excel-phobic users typing into
them, I want to avoid personally running this macro for each cell that
needs expansion. Unfortunately, my _very_ rudimentary VBA skills are of
no help.

Given that, I have several questions:


- Can I have the macro run automatically for each sheet, checking all
the merged cells (or simply all cells), when the user saves or exits?

- Can I have the macro check every single cell in the workbook? I'd
like to run this version manually.

- Can the macro activation event be when the user has finished
entering text and moves to a new cell whether by


- tabbing,
- hitting enter, or
- clicking on the next cell they want to modify?
If so, does anyone know how expensive this would be in terms of

time
and memory? All my users are accessing the workbook remotely and
already have a good deal of lag due to outdated equipment.


*'Jim Rech's AutoFitMergedCellRowHeight Code'
(http://tinyurl.com/aknxy)


--
JLC
------------------------------------------------------------------------
JLC's Profile:

http://www.excelforum.com/member.php...o&userid=28014
View this thread: http://www.excelforum.com/showthread...hreadid=488929



  #3   Report Post  
Posted to microsoft.public.excel.programming
JLC JLC is offline
external usenet poster
 
Posts: 1
Default how do I create event-activated macros that check every cell?


That works exactly how I'd hoped -except- that it changes the width o
the first column in the merged cell. Can we change the code so that i
doesn't alter column widths?

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)

I can't wait until I'm able to do some of this on my own... ;

--
JL
-----------------------------------------------------------------------
JLC's Profile: http://www.excelforum.com/member.php...fo&userid=2801
View this thread: http://www.excelforum.com/showthread.php?threadid=48892

  #4   Report Post  
Posted to microsoft.public.excel.programming
JLC JLC is offline
external usenet poster
 
Posts: 1
Default how do I create event-activated macros that check every cell?


Nevermind. When I turn on sheet protection and allow formatting of cell
row, and column, the macro works perfectly. Of course, I don't want m
users actually doing any formatting. If they figure out they can chang
things, there's no telling what will happen. Any suggestions about ho
to skirt this issue?

Thanks so much!
j

--
JL
-----------------------------------------------------------------------
JLC's Profile: http://www.excelforum.com/member.php...fo&userid=2801
View this thread: http://www.excelforum.com/showthread.php?threadid=48892

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how do I create event-activated macros that check every cell?

If you turn full protection on with a password, and then in the code, turn
it off, do your stuff, and then turn it back on.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"JLC" wrote in message
...

Nevermind. When I turn on sheet protection and allow formatting of cell,
row, and column, the macro works perfectly. Of course, I don't want my
users actually doing any formatting. If they figure out they can change
things, there's no telling what will happen. Any suggestions about how
to skirt this issue?

Thanks so much!
jc


--
JLC
------------------------------------------------------------------------
JLC's Profile:

http://www.excelforum.com/member.php...o&userid=28014
View this thread: http://www.excelforum.com/showthread...hreadid=488929





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
Cells change color when another cell is activated or typed with an Geauxfish Excel Discussion (Misc queries) 5 July 14th 09 09:05 PM
How do I create If/Then Macros contingent on cell values? tbonescott Excel Programming 1 October 6th 05 12:29 AM
Check File Name before Save Event ExcelMonkey[_170_] Excel Programming 0 September 29th 04 09:15 AM
Check File Name before Save Event ExcelMonkey[_169_] Excel Programming 1 September 29th 04 01:46 AM
check folder event Mark[_17_] Excel Programming 6 June 18th 04 03:08 PM


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