LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro inside of Macro

2 part question, 1st part:
How do I change this macro from looking at 1 highlighted merge cell to
run, to running the whole worksheet merge cells.

Sub AutoFitMergedCellRowHeight()
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range, RangeWidth As Single
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
If ActiveCell.MergeCells Then
With ActiveCell.MergeArea
If .Rows.Count = 1 And .WrapText = True Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
ActiveCellWidth = ActiveCell.ColumnWidth
RangeWidth = .Width
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth +
MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
While .Cells(1).Width < RangeWidth
.Cells(1).ColumnWidth = .Cells(1).ColumnWidth + 0.5
Wend
.Cells(1).ColumnWidth = .Cells(1).ColumnWidth - 0.5
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight PossNewRowHeight, _
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
End Sub

2nd part:
How do I put the above macro into the macro below:

Print and Save Macro

Dim Msg, Style, Title, Help, Ctxt, Response, MyString
'
' Save Current Spreadsheet

Sheets("CTL Report").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True

' commented out below Save since will be read-only copy
' ActiveWorkbook.Save

'Check if user has entered correct report date

DateEntry = Range("Date_Entry").Value
DateofRpt = Format(DateEntry, "MM-DD-YY")
ShiftEntry = Range("Shift_Entry").Value

Msg = "Do you want to release " & DateofRpt & " " & ShiftEntry & "?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Please Verify Date and Shift"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then

' Strip current of formulas

Sheets("CTL Report").Select
' Unprotect Sheet
ActiveSheet.Unprotect
Cells.Select
Range("b3").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("b3").Select
Application.CutCopyMode = False


' Save current As another sheet in archives - PLUG IN NORCO
DIRECTORY STRUCTURE
' You'll be keeping the master copy in a directory like
S:\lab_shift_turnover
' And you'll have an Archives folder under that, and a folder for the
year under that
' This release function will save a copy of the report into the
archives
' With the date and shift as a part of the report name

' For other reports, substitute area for Lite Oil

ChDir "\\Americas.shell.com\Americas\Chemicals\SCC
Norco\Department\Prod\ESP\Shift Reports"
DateEntry = Range("Date_Entry").Value
DateofRpt = Format(DateEntry, "MM-DD-YY")
ShiftEntry = Range("Shift_Entry").Value
FiletoSave = "file:\\Americas.shell.com\Americas\Chemicals\ SCC
Norco\Department\Prod\ESP\Shift Reports\ " & DateofRpt & " " &
ShiftEntry
ActiveWorkbook.SaveAs Filename:=FiletoSave, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=True, CreateBackup:=False
Sheets("CTL Report").Select
Cells.Select
Range("b3").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Sheets("CTL Report").Select
ActiveSheet.PrintOut , Copies:=1
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Range("B3").Select

ActiveWorkbook.Save

End If
'
End Sub

 
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
grouping inside a macro deepika :excel help[_2_] Excel Discussion (Misc queries) 1 February 20th 08 08:46 AM
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Input box inside a macro Drummy Excel Discussion (Misc queries) 3 June 7th 06 10:49 AM
Macro inside another macro? thrava Excel Discussion (Misc queries) 3 February 2nd 05 01:25 AM


All times are GMT +1. The time now is 08:05 AM.

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"