You are on page 1of 201

= V4 Outline MultiLine NoSorting TabWidth=30

H="Mackrows"
Collection of all my macroes

To keep excell running smoothly, all these shall be my macro library.

2012-04-22 07:34:16 'C:\Documents and Settings\Administrator\My


Documents\My Workbooks and
' Excel Documents\Default file location\macros.otl

C:\Documents and Settings\Administrator\My Documents\My Workbooks and Excel


Documents\Default file location
C:\Documents and Settings\Administrator\My Documents\My Workbooks and Excel
Documents\Default file location\Macaroes_)(.otl
2012-04-30 01:04:18

'� Turn off calculation and screen refresh while macro is running. Be
' sure to restore settings when the macro ends. Some supposedly reset
' automatically but later releases tend to require you to reset.
' Macros may terminate abnormally so don�t use without that thought in
' mind. The examples below do not save current settings and restore
' them but assume normal usage is in effect.

'Screen flickering is usually the result of bad coding, but turning


' off Screen Updating will eliminate the blinking, and speed up a
' macro. Turning off calculation can have a more dramatic effect on
' improving performance. Use of Special Cells and restriction to used
' range will greatly improve coding.

'Turning off ScreenUpdating and Calculation are the easiest changes to


' implement. Application.ScreenUpdating = False
'Application.Calculation = xlCalculationManual
' ' ooo Your code here ooo
'Application.Calculation = xlCalculationAutomatic
'Application.ScreenUpdating = True
'

'Prior to XL97 (Excel 5 and Excel 97) use


'Application.Calculation = xlManual 'prior to XL97
'Application.Calculation = xlAutomatic 'prior to XL97
' alternative coding: restores previous settings:

' Dim savCalc As Long, savScrnUD As Boolean


' savCalc = Application.Calculation
' savScrnUD = Application.ScreenUpdating
' Application.Calculation = xlCalculationAutomatic
' Application.ScreenUpdating = True
' ' ooo Your code here ooo
'done:
' Application.Calculation = savCalc
' Application.ScreenUpdating = savScrnUD

'I always want calculation on and there are too many bad macros that
' fail and macro of my own that fail during testing so I use the
' version on the left above. The code on the right above is more
' correct but prone to problems of leaving calculation off.
'For most VBA actions, you don�t have to select the sheet or cell.
' Look for such coding to be reworked/removed, you might even be able
' to remove the need to suppress screen updating if the appearance of
' the screen is not changed. (Brian Wilson Example: 2000-12-28)

'Are there any Worksheet_Change events.

'Related to last row problems, macros can take forever to run if they
' loop through all possible columns and rows instead of restricting
' activity to the used area. Examples where such failures commonly
' occur: deleting rows with certain content, inserting rows or
' columns, selecting an entire column and macro processes entire
' column instead of cells in the active area.

'In a test of one macro adding DIM statements appeared to increase


' time 30% contrary to good coding practices. Nevertheless, by
' dimensioning variables you simplify code writing and maintenance and
' avoid some additional problems. Turning off screenupdating saved
' about 12%, but turning off calculation saved an additional whopping
' 75%.

'Use SpecialCells to reduce selection to cell types of interest


' (constants, formulas, comments, visible, etc.). SpecialCells is
' automatically limited to the used range, which eliminates processing
' every single cell in a selected column, if a column is selected.
' Examples range from 366 seconds without using SpecialCells, to .040
' seconds by reducing selection with SpecialCells as seen on Proper,
' and other Text changes -- Use of Special Cells also see notations on
' same page.

'Dimensioning variables for use with Options Explicit. (#dimensioning)


' If you have simply used Dim xyz as variant you can find out the
' actual type that you used with MsgBox typename(xyz) so you can
' replace variant by its actual type. (see vba.htm for more
' information).

H=" Hyperlink to VBA module"


Hyperlink to VBA module
In Excel 97: Insert > Hyperlink: In �Named location in file (optional):� put the
name of the procedure.
So if the procedure name is MyProc, you would enter �MyProc�.
In Excel 2000: Insert > Hyperlink: Click on �Existing File or Web Page�,
then in �Type the file or Web-page name� put the name of a procedure preceded by a
hash (#).
So if the procedure name is MyProc, you would enter �#MyProc�.
In Excel 2002 (XP): Insert > Hyperlink: Click on �Existing File or Web Page�,
then in �Address� put the name of a procedure preceded by a hash (#).
So if the procedure name is MyProc, you would enter �#MyProc�.

H="'''Widening The Defined Name Box"


'''Widening The Defined Name Box
'''
''' In Excel 2003 and earlier, the defined name box cannot be resized, and it
'''truncates the display of names at about 16 characters. So, if you have two
'''long names like SomeLongDefinedNameOne and SomeLongDefinedNameTwo, you
'''cannot tell which is which in the Name Box dropdown. However, using a bit
'''of code, you can expand the width of the drop down list. This code will
'''not widen the name box itself, as it appears on the formula bar, but widens
'''the drop down list. The code to do this is shown below.
''Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
'' (ByVal lpClassName As String, _
'' ByVal lpWindowName As String) As Long
''
''Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
'' (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
'' ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
''
''Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
'' (ByVal hwnd As Long, ByVal wMsg As Long, _
'' ByVal wParam As Long, lParam As Any) As Long
''
''Sub WidenNameBoxDrop2()
'' Dim Res As Long
'' Const CB_SETDROPPEDWIDTH = 352
'' Const cWidth = 420 '< Change To Desire Width in Pixels
'' Res = SendMessage( _
'' FindWindowEx( _
'' FindWindowEx( _
'' FindWindow("XLMAIN", Application.Caption) _
'' , 0, "EXCEL;", vbNullString) _
'' , 0, "combobox", vbNullString), _
'' CB_SETDROPPEDWIDTH, cWidth, 0)
''End Sub
___________________________________________________________________________________
_________________
''
''' Put all of the code shown above in some code module, and then in your
'''Auto_Open procedure or in the Workbook_Open procedure call the
'''WidenNameBoxDrop2 procedure. For example,
''Sub Auto_Open()
'' WidenNameBoxDrop2
''End Sub
___________________________________________________________________________________
_________________

H="Sub OutlineHolistica()"
Sub OutlineHolistica()
'
' OutlineHolistica Macro
' Macro recorded 2012-04-20 by ediblesound
'

'

Range("A2:C2").Select
Range("C2").Activate
With ActiveSheet.Outline
.AutomaticStyles = False
.SummaryRow = xlAbove
.SummaryColumn = xlRight
End With
Selection.Columns.Group
Range("A2:B2").Select
Range("B2").Activate
Selection.Columns.Group
Range("A2").Select
Selection.Columns.Group
Range("F2:I2").Select
Selection.Columns.Group
Range("F1:AP2").Select
Range("F2").Activate
' Selection.Columns.Ungroup
Selection.Columns.Group
Range("F2:I2").Select
Selection.Columns.Group
Range("K2:N2").Select
Selection.Columns.Group
Range("P2:R2").Select
Selection.Columns.Group
Range("T2:V2").Select
Selection.Columns.Group
Range("X2:Z2").Select
Selection.Columns.Group
Range("AB2:AD2").Select
Selection.Columns.Group
Range("AF2:AH2").Select
Selection.Columns.Group
Range("AJ2:AL2").Select
Selection.Columns.Group
Range("AF2:AM2").Select
Selection.Columns.Group
Range("AR2:AT2").Select
Selection.Columns.Group
Range("AR2:AV2").Select
Selection.Columns.Group
Range("AR1:DS3").Select
Range("AR2").Activate
Selection.Columns.Group
Range("AX2:BA2").Select
Selection.Columns.Group
Range("BC2:BF2").Select
Selection.Columns.Group
Range("BH1:BM1").Select
Selection.Columns.Group
Range("BH1:DR3").Select
Selection.Columns.Group
Range("BO1:BP1").Select
Selection.Columns.Group
Range("BR1:BT1").Select
Selection.Columns.Group
Range("BV1:CC1").Select
Selection.Columns.Group
Range("CE1:CT3").Select
Selection.Columns.Group
Range("CV1:CZ1").Select
Range("CZ1").Activate
Selection.Columns.Group
Range("DB1:DI1").Select
Selection.Columns.Group
Range("DL1:DQ1").Select
Selection.Columns.Group
Range("DU1").Select
' ActiveWindow.SmallScroll Down:=-6
' Windows("ML20120_Quick (version 1).xls").Activate
' Windows("Book4").Activate
' ActiveWindow.SmallScroll Down:=-18
' Windows("ML20120_Quick (version 1).xls").Activate
' Range("B2234").Select
' Application.Goto Reference:="R1C1"
' Windows("Book4").Activate
Range("B2").Select
Selection.Rows.Group
Range("A4:A16").Select
Selection.Rows.Group
Range("A7:A16").Select
Selection.Rows.Group
Range("A8:A10").Select
Selection.Rows.Group
Range("A12:A16").Select
Selection.Rows.Group
Range("A18:A40").Select
Selection.Rows.Group
Range("B19:B40").Select
Selection.Rows.Group
Range("B19").Select
End Sub
___________________________________________________________________________________
_________________

H="Sub Explicator()"
Sub Explicator()
'
' Explicator Macro
' Macro recorded 2012-04-20 by ediblesound
'

'
ActiveCell.Offset(0, 9).Columns("A:E").EntireColumn.Select
Selection.Insert Shift:=xlToRight
Selection.Interior.ColorIndex = 2
Selection.Clear
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
With Selection.Interior
.Pattern = xlGray50
.PatternColorIndex = 12
End With
Selection.Interior.PatternColorIndex = 12
ActiveCell.Offset(0, -4).Range("A1:D5").Select
ActiveCell.Range("A1:D5").Select
ActiveCell.Offset(0, -5).Columns("A:E").EntireColumn.Select
Selection.Interior.PatternColorIndex = 12
Selection.Interior.Pattern = xlGray50
ActiveCell.Offset(0, 5).Range("A1:D5").Select
ActiveCell.Offset(1, 0).Range("A1:D5").Select
ActiveCell.Offset(5, 0).Range("A1").Activate
ActiveCell.Offset(-5, 0).Range("A1:D5").Select
Selection.Insert Shift:=xlDown
ActiveWindow.SmallScroll ToRight:=17
ActiveCell.Offset(0, 13).Columns("A:E").EntireColumn.Select
Selection.Insert Shift:=xlToRight
Selection.Clear
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
Selection.Interior.PatternColorIndex = 12
Selection.Interior.Pattern = xlGray50
ActiveCell.Offset(0, 9).Columns("A:E").EntireColumn.Select
Selection.Insert Shift:=xlToRight
Selection.Clear
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
With Selection.Interior
.Pattern = xlGray50
.PatternColorIndex = 12
End With
Selection.Interior.PatternColorIndex = 12
End Sub
___________________________________________________________________________________
_________________

H="Sub PushstaggerVertical()"
Sub PushstaggerVertical()
'
' PushstaggerVertical Macro
' Macro recorded 2012-04-20 by ediblesound
'
' Keyboard Shortcut: Ctrl+w
'
Selection.Insert Shift:=xlDown
Selection.Clear
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
With Selection.Interior
.Pattern = xlGray50
.PatternColorIndex = 12
End With
Selection.Interior.PatternColorIndex = 12
End Sub
___________________________________________________________________________________
_________________

H="Sub PushStaggererHorizontalismical()"
Sub PushStaggererHorizontalismical()
'
' PushStaggererHorizontalismical Macro
' Macro recorded 2012-04-20 by ediblesound
'
' Keyboard Shortcut: Ctrl+q
'
Selection.Insert Shift:=xlToRight
Selection.Clear
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
With Selection.Interior
.Pattern = xlGray50
.PatternColorIndex = 12
End With
Selection.Interior.PatternColorIndex = 12
Selection.Interior.ColorIndex = 2
End Sub
___________________________________________________________________________________
_________________

H="Sub ShowIt()"
Sub ShowIt()

Calender.Show

End Sub
___________________________________________________________________________________
_________________

H="' RowCompress Macro"


Sub RowCompress()
'
' RowCompress Macro
' Macro recorded 2012-03-29 by ediblesound
'
BeginRow = 16
EndRow = 376
ChkCol = 4

For RowCnt = BeginRow To EndRow


If Cells(RowCnt, ChkCol).Value < 2 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
End If
Next RowCnt
'
End Sub
___________________________________________________________________________________
_________________

H="Sub MTRowXpand()"
Sub MTRowXpand()
'
' RowCompress Macro
' Macro recorded 2012-03-29 by ediblesound
'
BeginRow = 16
EndRow = 376
ChkCol = 4
For RowCnt = BeginRow To EndRow
' If Cells(RowCnt, ChkCol).
'
' End If
If Cells(RowCnt, ChkCol).Value <> 88 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
' Cells(RowCnt, ChkCol).EntireRow.Height = 16
End If
Next RowCnt
'
End Sub
___________________________________________________________________________________
_________________

H="Sub HideColumnsAthroughC()"
Sub HideColumnsAthroughC()
' Adapted for use currently with the freshball strain of files. 2012-04-13 17:08:44
If Range("D391").Value = 0 Then
Columns("A:C").EntireColumn.Hidden = True
Else
Columns("A:C").EntireColumn.Hidden = False
End If

If Range("D391").Value = 0 Then
Columns("K:W").EntireColumn.Hidden = True
Else
Columns("K:W").EntireColumn.Hidden = False
End If

If Range("D391").Value = 0 Then
Columns("AB:AE").EntireColumn.Hidden = True
Else
Columns("AB:AE").EntireColumn.Hidden = False
End If

If Range("D391").Value = 0 Then
Columns("BC:BE").EntireColumn.Hidden = True
Else
Columns("BC:BE").EntireColumn.Hidden = False
End If

If Range("D391").Value = 0 Then
Columns("BI:BM").EntireColumn.Hidden = True
Else
Columns("BI:BM").EntireColumn.Hidden = False
End If

If Range("D391").Value = 0 Then
Columns("BU:CC").EntireColumn.Hidden = True
Else
Columns("BU:CC").EntireColumn.Hidden = False
End If

End Sub
___________________________________________________________________________________
_________________
H="Sub HideWorkBook()"
Sub HideWorkBook()
'
' HideWorkBook Macro
' Macro recorded 2012-03-31 by ediblesound
'
' Keyboard Shortcut: Ctrl+h
'
ActiveWindow.Visible = False
End Sub
___________________________________________________________________________________
_________________
Sub Unhide()
'
�}+--+{<+�Sub HideWorkBook()

H="' Unhide Macro"


' Macro recorded 2012-03-31 by ediblesound
'
' Keyboard Shortcut: xCxtxrxlx+xSxhxixfxtx+xUx
'
Sub Unhide
Windows("ML20120_Quick.xls").Visible = True
End Sub
___________________________________________________________________________________
_________________
' Unhide Macro

H="Sub MakeSquare()"
Sub MakeSquare()
Dim WPChar As Double
Dim DInch As Double
Dim Temp As String

Temp = InputBox("Height and width in inches?")


DInch = Val(Temp)
If DInch > 0 And DInch < 2.5 Then
For Each c In ActiveWindow.RangeSelection.Columns
WPChar = c.Width / c.ColumnWidth
c.ColumnWidth = ((DInch * 72) / WPChar)
Next c
For Each r In ActiveWindow.RangeSelection.Rows
r.RowHeight = (DInch * 72)
Next r
End If
End Sub
___________________________________________________________________________________
_________________
�}+--+{<+�Sub MakeSquare()

H="Sub FindCorruptConditionalFormat()"
Sub FindCorruptConditionalFormat()
' Selection.SpecialCells(xlCellTypeAllFormatConditions).Select
' For Each c In Selection.Cells
' For Each fc In c.FormatConditions
' If InStr(1, fc.Formula1, "#REF!", _
' vbBinaryCompare) > 0 Then
' MsgBox Prompt:=c.Address & ": " _
' & fc.Formula1, Buttons:=vbOKOnly
' End If
' Next fc
' Next c
End Sub
___________________________________________________________________________________
_________________
'
'' How do i get this to spit the references of these addresses onto a new sheet?!
2012-03-18 15:03:47

H="Sub RegionBorderMakerBR()"
Sub RegionBorderMakerBR()
'
' RegionBorderMakerV1 Macro
' Macro recorded 2012-04-01 by ediblesound
'

'
MsgBox Prompt:="Saving Active Workbook!", Buttons:=vbOKOnly
ActiveWorkbook.Save
'MsgBox Prompt:="Opening SeedSPot!", Buttons:=vbOKOnly
Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My Documents\My Workbooks and
Excel Documents\Default file location\RegionBorderSeedSPot.xls"
Windows("RegionBorderSeedSPot.xls").Activate
Application.Goto Reference:="RegiuonBorderSeedSPot"
Selection.Copy
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlMinimized
ActiveSheet.Paste
ActiveCell.Offset(0, 4).Columns("A:A").EntireColumn.ColumnWidth = 0.15
ActiveCell.Offset(0, 2).Columns("A:A").EntireColumn.ColumnWidth = 0.15
ActiveCell.Offset(4, 0).Range("A1").Select
Selection.RowHeight = 1.5
ActiveCell.Offset(-2, 0).Range("A1").Select
MsgBox Prompt:="Awesome! SeedSPot Cloney Planted! Sorry!, But you Get to Grow
it to your Region Desired, Until es Figures out how to do it via the
Macroawesomness, Thank you For Understanding! Lovely!", Buttons:=vbOKOnly
Selection.RowHeight = 1.5
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlNormal
' ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox Prompt:="Good Bye, Smoke some Pot Indeed! it is Lovely!",
Buttons:=vbOKOnly

End Sub
___________________________________________________________________________________
_________________

H="Sub RegionBorderMakerTR()"
Sub RegionBorderMakerTR()
'
' RegionBorderMakerV1 Macro
' Macro recorded 2012-04-01 by ediblesound
'

'
MsgBox Prompt:="Saving Active Workbook!", Buttons:=vbOKOnly
ActiveWorkbook.Save
MsgBox Prompt:="Opening SeedSPot!", Buttons:=vbOKOnly
Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My Documents\My Workbooks and
Excel Documents\Default file location\RegionBorderSeedSPot.xls"
Windows("RegionBorderSeedSPot.xls").Activate
Application.Goto Reference:="TRrbss"
Selection.Copy
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlMinimized
ActiveSheet.Paste
ActiveCell.Offset(0, 4).Range("A1").Select
Selection.RowHeight = 1.5
Selection.ColumnWidth = 0.15
ActiveCell.Offset(2, -2).Range("A1").Select
Selection.RowHeight = 1.5
Selection.ColumnWidth = 0.15
MsgBox Prompt:="Awesome! SeedSPot Cloney Planted! Sorry!, But you Get to Grow
it to your Region Desired, Until es Figures out how to do it via the
Macroawesomness, Thank you For Understanding! Lovely!", Buttons:=vbOKOnly
Selection.RowHeight = 1.5
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlNormal
' ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox Prompt:="Good Bye, Smoke some Pot Indeed! it is Lovely!",
Buttons:=vbOKOnly

End Sub
___________________________________________________________________________________
_________________

H="Sub RegionBorderMakerTL()"
Sub RegionBorderMakerTL()
'
' RegionBorderMakerV1 Macro
' Macro recorded 2012-04-01 by ediblesound
'

'
MsgBox Prompt:="Saving Active Workbook!", Buttons:=vbOKOnly
ActiveWorkbook.Save
MsgBox Prompt:="Opening SeedSPot!", Buttons:=vbOKOnly
Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My Documents\My Workbooks and
Excel Documents\Default file location\RegionBorderSeedSPot.xls"
Windows("RegionBorderSeedSPot.xls").Activate
Application.Goto Reference:="TLrbss"
Selection.Copy
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlMinimized
ActiveSheet.Paste
ActiveCell.Select
Selection.RowHeight = 1.5
Selection.ColumnWidth = 0.15
ActiveCell.Offset(2, 2).Range("A1").Select
Selection.RowHeight = 1.5
Selection.ColumnWidth = 0.15
MsgBox Prompt:="Awesome! SeedSPot Cloney Planted! Sorry!, But you Get to Grow
it to your Region Desired, Until es Figures out how to do it via the
Macroawesomness, Thank you For Understanding! Lovely!", Buttons:=vbOKOnly
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlNormal
' ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox Prompt:="Good Bye, Smoke some Pot Indeed! it is Lovely!",
Buttons:=vbOKOnly

End Sub
___________________________________________________________________________________
_________________

H="Sub RegionBorderMakerBL()"
Sub RegionBorderMakerBL()
'
' RegionBorderMakerV1 Macro
' Macro recorded 2012-04-01 by ediblesound
'

'
MsgBox Prompt:="Saving Active Workbook!", Buttons:=vbOKOnly
ActiveWorkbook.Save
MsgBox Prompt:="Opening SeedSPot!", Buttons:=vbOKOnly
Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My Documents\My Workbooks and
Excel Documents\Default file location\RegionBorderSeedSPot.xls"
Windows("RegionBorderSeedSPot.xls").Activate
Application.Goto Reference:="BLrbss"
Selection.Copy
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlMinimized
ActiveSheet.Paste
ActiveCell.Select
ActiveCell.Offset(4, 0).Range("A1").Select
Selection.RowHeight = 1.5
Selection.ColumnWidth = 0.15
ActiveCell.Offset(-2, 2).Range("A1").Select
Selection.RowHeight = 1.5
Selection.ColumnWidth = 0.15
MsgBox Prompt:="Awesome! SeedSPot Cloney Planted! Sorry!, But you Get to Grow
it to your Region Desired, Until es Figures out how to do it via the
Macroawesomness, Thank you For Understanding! Lovely!", Buttons:=vbOKOnly
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlNormal
' ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox Prompt:="Good Bye, Smoke some Pot Indeed! it is Lovely!",
Buttons:=vbOKOnly

End Sub
___________________________________________________________________________________
_________________

H="Sub TextBox2Cell()"
Sub TextBox2Cell()
' The following
'macro will create a text box directly over the selected cell, and size it to
'be exactly the same size as the selected cell:
'cntrl t
With ActiveCell
ActiveSheet.Shapes.AddTextbox _
msoTextOrientationHorizontal, .Left, _
.Top, .Width, .Height
End With
End Sub
___________________________________________________________________________________
_________________
'With a small change in the macro, you can modify it so that it will create
'text boxes that are just as large as whatever range of cells you have
'selected:
Sub TextBox2Selection()
If TypeName(Selection) = "Range" Then
With Selection
ActiveSheet.Shapes.AddTextbox _
msoTextOrientationHorizontal, .Left, _
.Top, .Width, .Height
End With
End If
End Sub
___________________________________________________________________________________
_________________
'
'Regardless of which approach you use to create the text box (manual or
'macro), it should be noted that if you resize the cell by changing the column
'width or row height, the size of the text box will also change to match the
'new cell size. cntrol I
Sub ChangeToRECTANGLE()
'

H="' ChangeToRECTANGLE Macro"


Sub ChangeToRECTANGLE
' Macro recorded 2012-04-06 by ediblesound
'
' Keyboard Shortcut: Ctrl+e
'
Selection.ShapeRange.AutoShapeType = msoShapeRectangle
End Sub
___________________________________________________________________________________
_________________
�}+--+{<+�''Sub Groupde()
'''

H="''' Macro3 Macro"


SubMacro3
''' Macro recorded 2012-04-10 by ediblesound
'''
''' Keyboard Shortcut: Ctrl+y
'''
'' ActiveWindow.SmallScroll Down:=-132
'' ActiveCell.Range("A1:A8").Select
'' Selection.Rows.Group
'' ActiveCell.Offset(9, 0).Range("A1").Select
''End Sub
___________________________________________________________________________________
_________________
''' see what this does...

H="Sub whiteONblack()"
Sub whiteONblack()
'
' whiteONblack Macro
' Macro recorded 2012-04-11 by ediblesound
'
' Keyboard Shortcut: Ctrl+n
'
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Selection.Font.ColorIndex = 1
Selection.Font.ColorIndex = 2
End Sub
___________________________________________________________________________________
_________________

H="Sub ListCFing()"
Sub ListCFing()
Dim NewSh As Worksheet
Dim x As Long
Dim Sh As Worksheet
Dim Rng As Range
Dim c As Range
Dim FC As FormatConditions
Dim Cond As FormatCondition
Dim CondNo As Integer
x = 1
Application.ScreenUpdating = False
Set NewSh = Worksheets.Add
With NewSh
.Cells(x, 1) = "Sheet"
.Cells(x, 2) = "Cell"
.Cells(x, 3) = "No"
.Cells(x, 4) = "Type"
.Cells(x, 5) = "Operator"
.Cells(x, 6) = "Formula1"
.Cells(x, 7) = "Formula2"
.Range(.Cells(x, 1), .Cells(x, 7)).Font.Bold = True
End With
For Each Sh In ThisWorkbook.Worksheets
Set Rng = Sh.UsedRange
On Error Resume Next
Set Rng = Rng.SpecialCells(xlCellTypeAllFormatConditions)
If Err Then GoTo None
For Each c In Rng

Set FC = c.FormatConditions

CondNo = 0
For Each Cond In FC
x = x + 1
CondNo = CondNo + 1
With NewSh
.Cells(x, 1) = Sh.Name
.Cells(x, 2) = c.Address(0, 0)
.Cells(x, 3) = CondNo
Select Case Cond.Type
Case xlCellValue: .Cells(x, 4) = "Value"
Case xlExpression: .Cells(x, 4) = "Expression"
End Select
Select Case Cond.Operator
Case xlBetween: .Cells(x, 5) = "Between"
Case xlEqual: .Cells(x, 5) = "="
Case xlGreater: .Cells(x, 5) = ">"
Case xlGreaterEqual: .Cells(x, 5) = ">="
Case xlLess: .Cells(x, 5) = "<"
Case xlLessEqual: .Cells(x, 5) = "<="
Case xlNotBetween: .Cells(x, 5) = "NotBetween"
Case xlNotEqual: .Cells(x, 5) = "<>"
End Select
.Cells(x, 6).NumberFormat = "@"
.Cells(x, 6) = Cond.Formula1
.Cells(x, 7).NumberFormat = "@"
.Cells(x, 7) = Cond.Formula2
End With
Next Cond

Next c
None:
Next Sh
NewSh.UsedRange.EntireColumn.AutoFit
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________

H="'AddressVolatile"
'Preeminent Macro to date 2012-04-05 23:29:27
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
' Range("A1").Value = Selection.Address
End Sub
___________________________________________________________________________________
_________________
Public Function CurrentCell() As String
Application.Volatile
CurrentCell = Selection.Address
End Function

'The inclusion of the Application.Volatile


'method means that every time the worksheet
'is recalculated, this function (macro) is
'again run. To use the macro you can place
'the following in any cell desired, including A1:
'=CurrentCell

H="'Datestomper"
Private Sub Worksheet_Change(ByVal Target As Range)
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub

If Not Intersect(Target, Range("='Log and QuickView'!$J$753:$J$1112")) Is


Nothing Then

With Target(1, 0)

.Value = Now

End With

End If

End Sub
___________________________________________________________________________________
_________________

'and so how do I change formatting to yyyy-mm-dd HH:mm:ss.000,


'and how do I get it to put the value of now to milliseconds?
' ' a single quote comments
'and now I have a LONG way to watch all 35 or so columns for new data, and i
'nsert for each column, the now stomp in the corresponding D row.!
' 2012-03-13
22:57:42
'
' adjusted qucikly for immediate use!
' 2012-03-14
10:45:27
'
' So perhaps How Might I be able to get it to APPEND new date
' info for each edit of the same cell?

H="Sub SeedSpotPositionArchForSight()"
Sub SeedSpotPositionArchForSight()
'
' SeedSpotPositionArchForSight Macro
' Macro recorded 2012-04-20 by ediblesound
'

'
MsgBox Prompt:="Saving Active Workbook!", Buttons:=vbOKOnly
ActiveWorkbook.Save
MsgBox Prompt:="Opening SeedSPot!", Buttons:=vbOKOnly
Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My Documents\My Workbooks and
Excel Documents\Default file location\RegionBorderSeedSPot.xls"
Windows("RegionBorderSeedSPot.xls").Activate
Sheets("Sheet2").Select
ActiveSheet.Shapes.Range(Array("Group 3", "Group 6", "Group 9")).Select
Selection.Copy
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlMinimized
ActiveSheet.Paste
MsgBox Prompt:="Excellent! Now you can use this template to help line up your
initial target cell for the SeedSpot Placement!", Buttons:=vbOKOnly
Windows("RegionBorderSeedSPot.xls").Activate
ActiveWindow.WindowState = xlNormal
' ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox Prompt:="Good Bye, Smoke some Pot Indeed! it is Lovely!",
Buttons:=vbOKOnly

End Sub
___________________________________________________________________________________
_________________

H="Sub tl()"
Sub tl()
'
' tl Macro
' Macro recorded 2012-04-16 by ediblesound
'

'
With All.ActiveWindows
.Top = 1.70588235294118
.Left = 1.70588235294118
End With

End Sub
___________________________________________________________________________________
_________________

H="SOmeLockiones"
'Hi,
'Here are a couple of macros I use.
'Enter them into "ThisWorkbook Item"
'ie, once in the workbook, press Alt+F11 to activate the VBE
'Locate the worlbook in the Project window
'Double-click the project to display ite items, if necessary.
'Double-click the ThisWorkbook item. - The VBE displays an empty code window for
the ThisWorkbook object
'In the Code window, select Workbook from the Object (left) drop down list, and
enter the following vba code.
'Note, I have a couple of lines of code that I enter to limit the scrolling area to
stop people scrolling down to the bottom of the page, and also another line of code
to limit access to only unlocked cells.
'
'Dont forget to return the caption to "Excel and the file name" when you are
finished.
'Change the caption from Excel and file name to whatever you want
Application.Caption = "My name and any other information here"

'Limits scroll area to A1:H7 in Sheet1..change sheet name if you have to


Worksheets("Sheet1").ScrollArea = "=Sheet1!$AY$51:$BF$63"

'Limits access to only unlocked cells in SAheet1..change name if you have to


Worksheets("Sheet1").EnableSelection = xlUnlockedCells

End Sub
___________________________________________________________________________________
_________________

Private Sub Workbook_BeforeClose(Cancel As Boolean)

'Reset caption to standard caption.


Application.Caption = ""

End Sub
___________________________________________________________________________________
_________________

H="SOrtBy Date macro"


Humar March 20, 2010 at 08:21:08 Pacific
Hi,
Here is an extension of the macro to include a sort - by date and dates before
today are formatted in red font.
For my test, I had the dates in column B, but you can change this in one line of
code:
'date column letter - change as required
strDateCol = "B"
The macro excludes the source worksheet from the sorting and date font color
change.
If you want to exclude any other worksheets, change this line from
'exclude the source worksheet
If wsEach.Name <> strSourceWsName Then
to something like this:
If wsEach.Name <> strSourceWsName And wsEach.Name <> "MySheetToExclude" Then
Macro with Sort:
Option Explicit

Private Sub CommandButton1_Click()


Dim rngStart As Range
Dim rngEnd As Range
Dim rngCell As Range
Dim rngDestEnd As Range
Dim strWsName As String
Dim wsEach As Worksheet
Dim strSourceWsName As String
Dim strDateCol As String
Dim rngDateStart As Range
Dim rngDateEnd As Range

On Error GoTo ErrHnd


'date column letter - change as required
strDateCol = "B"

'turn off screen updating to stop flicker


Application.ScreenUpdating = False

'get this worksheet's name (the source worksheet)


strSourceWsName = ActiveSheet.Name

'set start of data (range containing names for worksheets)


Set rngStart = Worksheets("Sheet1").Range("A2")

'set end of range


Set rngEnd = Worksheets("Sheet1").Range("A" & CStr(Application.Rows.Count)) _
.End(xlUp)

'Loop through all cells with names


For Each rngCell In Range(rngStart, rngEnd)
'get name
strWsName = rngCell.Text
'exclude the main inelligible names
If strWsName <> "" And InStr(1, strWsName, "/") = 0 _
And InStr(1, strWsName, "\") = 0 And InStr(1, strWsName, "?") = 0 _
And InStr(1, strWsName, "*") = 0 And InStr(1, strWsName, "[") = 0 _
And InStr(1, strWsName, "]") = 0 Then
'test if worksheet exists
On Error Resume Next
If Worksheets(strWsName) Is Nothing Then
'worksheet does not exist, so create & name it
On Error GoTo ErrHnd
'create new sheet
Worksheets.Add After:=Worksheets(Worksheets.Count)
'name new sheet
Worksheets(Worksheets.Count).Name = strWsName
End If
'if name was valid for a worksheet, copy row to that named sheet
'find empty row after end of destination data
Set rngDestEnd = Worksheets(strWsName). _
Range("A" & CStr(Application.Rows.Count)).End(xlUp).Offset(1, 0)
rngCell.EntireRow.Copy
rngDestEnd.PasteSpecial (xlPasteValuesAndNumberFormats)
Else
'name not valid - warn user - but ignore empty cells
If strWsName <> "" Then
MsgBox strWsName & " is not a valid worksheet name", vbOKOnly, _
"Worksheet Names"
End If
End If
Next rngCell

'clear copy marquee


Application.CutCopyMode = False

'go through each worksheet, except the source worksheet


For Each wsEach In ActiveWorkbook.Worksheets()
'exclude the source worksheet
If wsEach.Name <> strSourceWsName Then
'sort the rows by the date column
'Sort - assumes one header row & uses current region
wsEach.Range("A1").Sort _
Key1:=wsEach.Range(strDateCol & "1"), _
Order1:=xlAscending, _
Header:=xlYes

'now change text color for all dates earlier than today
'set start of date column
Set rngDateStart = wsEach.Range(strDateCol & "2")
'set end of date column
Set rngDateEnd = wsEach.Range(strDateCol & CStr(Application.Rows.Count)) _
.End(xlUp)
For Each rngCell In wsEach.Range(rngDateStart, rngDateEnd)
'use integers to exclude any time information stored with dates
If Int(rngCell.Value) < Int(Now) Then
rngCell.Font.Color = RGB(200, 0, 20)
Else
rngCell.Font.Color = RGB(0, 0, 0)
End If
Next rngCell
End If
Next wsEach

'restore screen updating


Application.ScreenUpdating = True
Exit Sub

'error handler
ErrHnd:
Err.Clear
'restore screen updating
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
'Regards

H="'HyperlinkFileList"

'Code:
i'nstructions for use

Option Compare Text


Option Explicit

Function Excludes(Ext As String) As Boolean


'Function purpose: To exclude listed file extensions from hyperlink listing

Dim X, NumPos As Long

'Enter/adjust file extensions to EXCLUDE from listing here:


X = Array("exe", "bat", "dll", "zip")

On Error Resume Next


NumPos = Application.WorksheetFunction.Match(Ext, X, 0)
If NumPos > 0 Then Excludes = True
On Error Goto 0

End Function
Sub HyperlinkFileList()
'Macro purpose: To create a hyperlinked list of all files in a user
'specified directory, including file size and date last modified
'NOTE: The 'TextToDisplay' property (of the Hyperlink object) was added
'in Excel 2000. This code tests the Excel version and does not use the
'Texttodisplay property if using XL 97.

Dim fso As Object, _


ShellApp As Object, _
File As Object, _
SubFolder As Object, _
Directory As String, _
Problem As Boolean, _
ExcelVer As Integer

'Turn off screen flashing


Application.ScreenUpdating = False

'Create objects to get a listing of all files in the directory


Set fso = CreateObject("Scripting.FileSystemObject")

'Prompt user to select a directory


Do
Problem = False
Set ShellApp = CreateObject("Shell.Application"). _
Browseforfolder(0, "Please choose a folder", 0, "c:\\")

On Error Resume Next


'Evaluate if directory is valid
Directory = ShellApp.self.path
Set SubFolder = fso.GetFolder(Directory).Files
If Err.Number <> 0 Then
If MsgBox("You did not choose a valid directory!" & vbCrLf & _
"Would you like to try again?", vbYesNoCancel, _
"Directory Required") <> vbYes Then Exit Sub
Problem = True
End If
On Error Goto 0
Loop Until Problem = False

'Set up the headers on the worksheet


With ActiveSheet
With .Range("A1")
.Value = "Listing of all files in:"
.ColumnWidth = 40
'If Excel 2000 or greater, add hyperlink with file name
'displayed. If earlier, add hyperlink with full path displayed
If Val(Application.Version) > 8 Then 'Using XL2000+
.Parent.Hyperlinks.Add _
Anchor:=.Offset(0, 1), _
Address:=Directory, _
TextToDisplay:=Directory
Else 'Using XL97
.Parent.Hyperlinks.Add _
Anchor:=.Offset(0, 1), _
Address:=Directory
End If
End With
With .Range("A2")
.Value = "File Name"
.Interior.ColorIndex = 15
With .Offset(0, 1)
.ColumnWidth = 15
.Value = "Date Modified"
.Interior.ColorIndex = 15
.HorizontalAlignment = xlCenter
End With
With .Offset(0, 2)
.ColumnWidth = 15
.Value = "File Size (Kb)"
.Interior.ColorIndex = 15
.HorizontalAlignment = xlCenter
End With
End With
End With

'Adds each file, details and hyperlinks to the list


For Each File In SubFolder
If Not Excludes(Right(File.path, 3)) = True Then
With ActiveSheet
'If Excel 2000 or greater, add hyperlink with file name
'displayed. If earlier, add hyperlink with full path displayed
If Val(Application.Version) > 8 Then 'Using XL2000+
.Hyperlinks.Add _
Anchor:=ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0), _
Address:=File.path, _
TextToDisplay:=File.Name
Else 'Using XL97
.Hyperlinks.Add _
Anchor:=ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0), _
Address:=File.path
End If
'Add date last modified, and size in KB
With .Range("A65536").End(xlUp)
.Offset(0, 1) = File.datelastModified
With .Offset(0, 2)
.Value = WorksheetFunction.Round(File.Size / 1024, 1)
.NumberFormat = "#,##0.0"
End With
End With
End With
End If
Next

End Sub
___________________________________________________________________________________
_________________

'
'How to use:
'Copy above code.
'In Excel press Alt + F11 to enter the VBE.
'Press Ctrl + R to show the Project Explorer.
'Right-click desired file on left (in bold).
'Choose Insert -> Module.
'Paste code into the right pane.
'Scroll to find the "Function Excludes" function
'Review the line starting "X=Array". Remove any extension you DO want
' to see in the list, and add any extension you DONT want to see in
' the list. (For example if you dont want to see Word documents, add:
' ,"doc" after the "zip" portion of the line)
'Press Alt + Q to close the VBE.
'Save workbook before any other changes.

'Test the code:


'Select (or create) a blank worksheet
'From Excel, run macro HyperlinkFileList by pressing Alt+F8.
'Choose a directory from the explorer window that pops up, and click
' Okay
'If you have not selected a valid directory (My computer, Network
' Neighborhood, etc...) you will be asked if you would like to try
' again
'Your list will be created

H="'MacroFormulasToWord"
'
'a macro that actually pulled the formulas and placed them in a Word
' document for you. The following Excel macro will do just that:

Sub WriteFormulasToWord()
Dim Wrd As New Word.Application
Dim CellTxt As String
Dim CellAddr As String
Dim SRow As Long
Dim SCol As Long

Wrd.Visible = True
Wrd.Documents.Add

Wrd.Selection.TypeText Text:="List of the Formulas of Sheet """ _


& ActiveSheet.Name & """ in Workbook """ _
& ActiveWorkbook.Name & """."
Wrd.Selection.TypeText Text:=vbCrLf & vbCrLf

'Change the following line to pick the number of columns


For SCol = 1 To 5
'Change the following line to pick the number of rows
For SRow = 1 To 10
If Cells(SRow, SCol).HasFormula Then
CellAddr = Chr(64 + SCol) & Trim(Str(SRow)) & vbTab
CellTxt = ActiveSheet.Cells(SRow, SCol).Formula
Wrd.Selection.TypeText Text:=CellAddr & CellTxt
Wrd.Selection.TypeText Text:=vbCrLf
End If
Next SRow
Wrd.Selection.TypeText Text:=vbCrLf
Next SCol
End Sub
___________________________________________________________________________________
_________________

'
'There are a couple of things to note in this macro. First of all, you
' can change the range of rows and columns over which the macro works
' by changing the noted For statements that use both SCol and SRow. In
' the example shown above, the macro pulls formulas from columns 1
' through 5 (A through E) and rows 1 through 10.

'In addition, this macro will not work properly unless you set up
' Excel macros to handle references to Word objects. You do that by
' following these steps within the VBA Editor:
'Choose References from the Tools menu. VBA displays the References
' dialog box. (See Figure 3.)

'Figure 3. The References dialog box.


'Scroll through the list of references until you see one called
' Microsoft Word Object Library. (There may be a version number
' included in the reference name, such as Microsoft Word 11.0 Object
' Library.)
'Make sure the check box to the left of the object library is selected.
'Click on OK.

'An advantage to using a macro to actually pull your formulas is that


' you can customize exactly what is placed in the Word document. In
' the case of this macro, the address of the cell is inserted,
' followed by a tab character, and then the actual formula. You could
' just as easily change the information inserted to be anything you
' need in your particular instance.

H="'macro set row col dimensions"


'This macro could go through the worksheets and set the column widths
'and row heights to what you need The following macro will perform
'these steps:
Private Sub Workbook_Open()
Dim wSheet As Worksheet

For Each wSheet In Worksheets


' Change to the columns you need
Columns("A:M").Select
' Change to the width you need
Selection.ColumnWidth = 12

' Change to the rows you need


Rows("1:15").Select
' Change to the height you need
Selection.RowHeight = 13
Next wSheet
End Sub
___________________________________________________________________________________
_________________

H="Sub CDLFRMTFNDR()"
Sub CDLFRMTFNDR()
Dim NewSh As Worksheet
Dim x As Long
Dim Sh As Worksheet
Dim Rng As Range
Dim c As Range
Dim FC As FormatConditions
Dim Cond As FormatCondition
Dim CondNo As Integer
x = 1
Application.ScreenUpdating = False
Set NewSh = Worksheets.Add
With NewSh
.Cells(x, 1) = "Sheet"
.Cells(x, 2) = "Cell"
.Cells(x, 3) = "No"
.Cells(x, 4) = "Type"
.Cells(x, 5) = "Operator"
.Cells(x, 6) = "Formula1"
.Cells(x, 7) = "Formula2"
.Range(.Cells(x, 1), .Cells(x, 7)).Font.Bold = True
End With
For Each Sh In ThisWorkbook.Worksheets
Set Rng = Sh.UsedRange
On Error Resume Next
Set Rng = Rng.SpecialCells(xlCellTypeAllFormatConditions)
If Err Then GoTo None
For Each c In Rng

Set FC = c.FormatConditions

CondNo = 0
For Each Cond In FC
x = x + 1
CondNo = CondNo + 1
With NewSh
.Cells(x, 1) = Sh.Name
.Cells(x, 2) = c.Address(0, 0)
.Cells(x, 3) = CondNo
Select Case Cond.Type
Case xlCellValue: .Cells(x, 4) = "Value"
Case xlExpression: .Cells(x, 4) = "Expression"
End Select
Select Case Cond.Operator
Case xlBetween: .Cells(x, 5) = "Between"
Case xlEqual: .Cells(x, 5) = "="
Case xlGreater: .Cells(x, 5) = ">"
Case xlGreaterEqual: .Cells(x, 5) = ">="
Case xlLess: .Cells(x, 5) = "<"
Case xlLessEqual: .Cells(x, 5) = "<="
Case xlNotBetween: .Cells(x, 5) = "NotBetween"
Case xlNotEqual: .Cells(x, 5) = "<>"
End Select
.Cells(x, 6).NumberFormat = "@"
.Cells(x, 6) = Cond.Formula1
.Cells(x, 7).NumberFormat = "@"
.Cells(x, 7) = Cond.Formula2
End With
Next Cond

Next c
None:
Next Sh
NewSh.UsedRange.EntireColumn.AutoFit
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
H="'Create an Anchored Shape (#anchor)"
'Create an Anchored Shape (#anchor)
'Creating a shape anchored to the four borders of a cell. Even though
'the shape is anchored to the four borders, you can manually move the
'image and change it's shape, but the image remains anchored to the
'four original points (cell's top, left, width, height)and will
'distort according to their movement of those borders. (see code on
'left below)

'A shape's default .Placement property value is xlMoveAndSize. Change


'it to xlFreeFloating if desired -- then the the image is anchored to
'the upper left corner of the spreadsheet and removal of columns does
'not affect it's position. (see code on xXrightXx -> below)

JE McGimpsey, public.excel, 2004-08-30.

With Range("J4")
ActiveSheet.Shapes.AddShape _
Type:=msoShapeSmileyFace, _
Left:=.Left, _
Top:=.Top, _
Width:=.Width, _
Height:=.Height
End With

With Range("K10")
With ActiveSheet.Shapes.AddShape( _
Type:=msoShapeSmileyFace, _
Top:=.Top, Left:=.Left, _
Width:=.Width, _
Height:=.Height)
.Placement = xlFreeFloating
End With
End With

H="Resizing Shapes (#resize)"


'Resizing Shapes (#resize)
'Sizes are in points so 4 * 72 is 4 inches. The following is a test
'and example you can add msgbox code to view results at various points
'if you wish to see something particular. Sub Macro19()
Dim wfactor As Double
Dim shp As Shape

'Delete all shapes to begin test


For Each shp In ActiveWorkbook.ActiveSheet.Shapes
shp.Delete '****** warning DELETE all Shapes found
Next shp

'Create some shapes


ActiveSheet.Shapes.AddShape(msoShapeRectangle, _
36#, 151.5, 202.5, 125.25).Select
ActiveSheet.Shapes.AddShape(msoShapeOval, _
544.5, 154.5, 57#, 41.25).Select

'Resize each shape to 4 inches height and width


For Each shp In ActiveWorkbook.ActiveSheet.Shapes
shp.Height = 4 * 72
shp.Width = 4 * 72
Next shp

'Rescale each shape to 2 inches width and scale height


For Each shp In ActiveWorkbook.ActiveSheet.Shapes
wfactor = 2 * 72 / shp.Width
shp.Height = shp.Height * wfactor
shp.Width = shp.Width * wfactor
Next shp

'insert an image and resize width


Dim PictureName As String
PictureName = "C:\copiedsite\dmcritchie\icons\bl-green.gif"
Range("A4").Select
ActiveSheet.Pictures.Insert(Picturename).Select
Selection.Width = 4 * 72
MsgBox TypeName(Selection) 'shows up as Picture
End Sub
___________________________________________________________________________________
_________________

H="Thread: Update should be done in different file"

'Hallo All,

'I have two excel files one is Main_data.xls and second one is
' Secondary_data.xls having some of the columns from Main_data.xls

'when every I add or change some data in Main_data.xls it should also


' change in Secondary_data.xls file.

'I have different columns in Main_data.xls in columns A, C, E when


' ever there is a change in data it should also be updated in the
' columns A, B, C of Secondary.xls file.

'kindly help me regarding this.

'I am attaching the sample files.

'Regards,
'Venu.

'
'Hi Venu,

'VB:
Sub GetExternalData()
Dim FilePath As String
Dim FileName As String
Dim FullName As String
Dim MyName

FilePath = "C:\Test" 'change to suit


FileName = "Main_data.xls"
FullName = FilePath & "\" & FileName
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=Excel Files;DBQ=" & FullName & ";DefaultDir=" & FilePath &
";Driver" _
), Array("Id=790;MaxBufferSize=2048;PageTimeout=5;")),
Destination:=Range("A2" _
))
.CommandText = Array( _
"SELECT `Sheet1$`.Name, `Sheet1$`.Scope, `Sheet1$`.Status" & Chr(13) & "" &
Chr(10) & "FROM `" & Left(FullName, Len(FullName) - 4) & "`.`Sheet1$` `Sheet1$`" _
) 'change the sheet name to suit
.Name = "Query"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
For Each MyName In ThisWorkbook.Names
If InStr(MyName.Name, "Query") > 0 Then
ActiveWorkbook.Names(MyName.Name).Delete
End If
Next MyName
End Sub
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/]
[/][/][/][/][/][/
\
+\_\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=
-\=-\=-_\=-\=-\-
}?}?}/}/}/]/}/]/]?}/}/}/}?}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}
?]/}?]/}?]/}?]/}?
><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)
(><)(><)(><)(><)(><
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

H="Ensuring Macros Are Enabled"

'This page illustrates a technique to allow a workbook to function


' only if macros are enabled.
'

'Introduction

'In large and complex workbooks and Excel-based applications, the


' workbook may work properly only if the user has macros enabled. If
' macros are disabled, you may not want the user to do anything. For
' security reasons, there is no way to force the user to enable
' macros. (If there were such a method, it would defeat the entire
' purpose of allowing macros to be disabled.) However, you can use
' code to make your workbook operational only if macros are enabled.

'This is accomplished by hiding every worksheet except one, which we


' call here the Introduction sheet. This introduction sheet does
' nothing and contains only a notice to the user that they must enable
' macros to use the workbook. The Workbook_Open event, which runs when
' the workbook is opened and macros are enabled, hides the
' introduction sheet and makes the other sheets visible (according to
' their normal Visible property), allowing full access to the
' workbook. If macros are not enabled, the Open event won't run and
' only the introduction sheet will be visible to the user.

'Then, in the Workbook_BeforeClose event, all worksheet except the


' introduction sheet are made very hidden. Only the introduction sheet
' is visible. Thus, the next time the workbook is opened, if macros
' are disabled, only the introduction sheet is visible.

'EXCEL SHEET VISIBILITY PROPERTIES: The visibility of a worksheet has


' one of three values: xlSheetVisible makes the sheet visible in the
' workbook;. xlSheetHidden, hides the sheet but allows the sheet to be
' made visible from the Sheet item on the Format menu; and
' xlSheetVeryHidden, which hides the sheet and does not allow the user
' to make the sheet visible. A sheet that is xlSheetVeryHidden can be
' made visible only through VBA code. The user cannot unhide very
' hidden sheets.

'The code on this page will preserve the Visible property of each
' sheet. Thus, if you have sheets other than the introduction sheet
' that need to remain hidden or very hidden, the code will accommodate
' those sheets. It will not make visible any sheet that normally is
' hidden or very hidden.

'The sheets' Visible property values are stored in a defined name so


' that the settings will be saved with the workbook. The Visible
' property of this defined name is False, so the user will not be able
' to change its value.
'When deploying your workbook, the last saved version, the one that is
' distributed to the end users, should have:
'The Introduction sheet Hidden (xlSheetVeryHidden)
'All sheets that should be visible to the user when macros are enabled
' visible (xlSheetVisible)

'It is assumed that the Application.EnableEvents property will be True


' when the workbook is opened and when it is closed. If EnableEvents
' is False, the workbook will behave as is macros are disabled, even
' if, in fact, macros are enabled.

'Complete VBA Code

'In the ThisWorkbook code module, paste the following code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)


''''''''''''''''''''''''''''''''''''''''''''''''
' Save the workbook's sheet visibility settings
' and hide all sheets except the introduction
' sheet. This Workbook_BeforeClose will run only
' if macros are enabled.
''''''''''''''''''''''''''''''''''''''''''''''''
SaveStateAndHide
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Private Sub Workbook_Open()


''''''''''''''''''''''''''''''''''''''''''''''''
' Unhide the sheets. This Workbook_Open event
' will run only if macros are enabled. If macros
' are not enabled, this code will not run and
' only the introduction sheet will be visible.
''''''''''''''''''''''''''''''''''''''''''''''''
UnHideSheets
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

'Paste all of the following code into a regular code module. Change
' the lines marked with '<<<< CHANGE to the appropriate values.

'C_SHEETSTATE_NAME is the name of a Defined Name in which the the


' Visible properties of all the worksheets are stored. There is no
' reason to change this value, but you can certainly do so.

'C_INTRO_SHEETNAME is the name of the worksheet that should be


' displayed if the workbook is opened with macros disabled. This sheet
' should contain a text to the user indicating that the workbook
' should be opened with macros enabled along with instructions on how
' to enable macros.

'C_WORKBOOK_PASSWORD is the password used to protect and unprotect the


' workbook. If your workbook has not protection, you can leave this
' value unchanged.

Option Explicit
Private Const C_SHEETSTATE_NAME = "SheetState"
Private Const C_INTRO_SHEETNAME = "Introduction" '<<<< CHANGE
Private Const C_WORKBOOK_PASSWORD = "abc" '<<<< CHANGE
___________________________________________________________________________________
_________________

Sub SaveStateAndHide()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SaveStateAndHide
' This is called from Workbook_BeforeClose.
' This procedure saves the Visible propreties of all worksheets
' in the workbook. This will run only if macros are enabled. It
' saves the Visible properties as a colon-delimited string, each
' element of which is the Visible property of a sheet. In the
' property string, C_INTRO_SHEETNAME is set to xlSheetVeryHidden
' so that if the workbook is opened with macros enabled, that
' sheet will not be visible. If macros are not enabled, only
' that sheet will be visible.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim S As String
Dim WS As Object
Dim N As Long
''''''''''''''''''''''''''''''''''''''''''''
' Protection settings. We must be
' able to unprotect the workbook in
' order to modify the sheet visibility
' properties. We will restore the
' protection at the end of this procedure.
''''''''''''''''''''''''''''''''''''''''''''
Dim HasProtectWindows As Boolean
Dim HasProtectStructure As Boolean

'''''''''''''''''''''''''''''''''''''''''''''''
' Save the workbook's protection settings and
' attempt to unprotect the workbook.
'''''''''''''''''''''''''''''''''''''''''''''''
HasProtectWindows = ThisWorkbook.ProtectWindows
HasProtectStructure = ThisWorkbook.ProtectStructure

ThisWorkbook.Unprotect Password:=C_WORKBOOK_PASSWORD

'''''''''''''''''''''''''''''''''''''''''''''''
' Make the introduction sheet visible
'''''''''''''''''''''''''''''''''''''''''''''''
ThisWorkbook.Worksheets(C_INTRO_SHEETNAME).Visible = xlSheetVisible
'''''''''''''''''''''''''''''''''''''''''''''''
' Delete the Name. Ignore error if it doesn't
' exist.
On Error Resume Next
'''''''''''''''''''''''''''''''''''''''''''''''
ThisWorkbook.Names(C_SHEETSTATE_NAME).Delete
Err.Clear
On Error GoTo 0
For Each WS In ThisWorkbook.Sheets
'''''''''''''''''''''''''''''''''''''''''''''''
' Create a string of the sheet visibility
' properties, separated by ':' characters.
' Do not put a ':' after the last sheet. Always
' set the visible property of the Introduction
' sheet to xlSheetVeryHidden. Don't put a ':'
' after the last sheet visible property.
'''''''''''''''''''''''''''''''''''''''''''''''
S = S & IIf(StrComp(WS.Name, C_INTRO_SHEETNAME, vbTextCompare) = 0, _
CStr(xlSheetVeryHidden), CStr(WS.Visible)) & _
IIf(WS.Index = ThisWorkbook.Sheets.Count, "", ":")
'''''''''''''''''''''''''''''''''''''''''''''''
' If WS is the intro sheet, make it visible,
' otherwise make it VeryHidden. This sets all
' sheets except C_INTRO_SHEETNAME to very
' hidden.
''''''''''''''''''''''''''''''''''''''''''''''''
If StrComp(WS.Name, C_INTRO_SHEETNAME, vbTextCompare) = 0 Then
WS.Visible = xlSheetVisible
Else
WS.Visible = xlSheetVeryHidden
End If
Next WS
''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Save the property string in a defined name.
''''''''''''''''''''''''''''''''''''''''''''''''''''''
ThisWorkbook.Names.Add Name:=C_SHEETSTATE_NAME, RefersTo:=Chr(39) & S,
Visible:=False

''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set the workbook protection back to what it was.
''''''''''''''''''''''''''''''''''''''''''''''''''''''
ThisWorkbook.Protect C_WORKBOOK_PASSWORD, _
structure:=HasProtectStructure, Windows:=HasProtectWindows

End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub UnHideSheets()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' UnHideSheets
' This is called by Workbook_Open to hide the introduction sheet
' and set all the other worksheets to their visible state that
' was stored when the workbook was last closed. The introduction
' sheet is set to xlSheetVeryHidden. This maro is executed only
' is macros are enabled. If the workbook is opened without
' macros enabled, only the introduction sheet will be visible.
' If an error occurs, make the intro sheet visible and get out.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim S As String
Dim N As Long
Dim VisibleArr As Variant
Dim HasProtectWindows As Boolean
Dim HasProtectStructure As Boolean

'''''''''''''''''''''''''''''''''''''''''''''''
' Save the workbook's protection settings and
' attempt to unprotect the workbook.
'''''''''''''''''''''''''''''''''''''''''''''''
HasProtectWindows = ThisWorkbook.ProtectWindows
HasProtectStructure = ThisWorkbook.ProtectStructure

ThisWorkbook.Unprotect Password:=C_WORKBOOK_PASSWORD

On Error GoTo ErrHandler:


Err.Clear
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Get the defined name that contains the sheet visible
' properties and clean up the string.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
S = ThisWorkbook.Names(C_SHEETSTATE_NAME).RefersTo
S = Mid(S, 4, Len(S) - 4)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set VisibleArr to an array of the visible properties,
' one element per worksheet.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
If InStr(1, S, ":", vbBinaryCompare) = 0 Then
VisibleArr = Array(S)
Else
VisibleArr = Split(S, ":")
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Loop through the array and set the Visible propety
' for each sheet. If we're processing the C_INTRO_SHEETNAME
' sheet, make it Visible (since it may be the only
' visbile sheet). We'll hide it later after the
' loop.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
For N = LBound(VisibleArr) To UBound(VisibleArr)
If StrComp(ThisWorkbook.Sheets(N - LBound(VisibleArr) + 1).Name,
C_INTRO_SHEETNAME) = 0 Then
ThisWorkbook.Sheets(C_INTRO_SHEETNAME).Visible = xlSheetVisible
Else
ThisWorkbook.Sheets(N - LBound(VisibleArr) + 1).Visible =
CLng(VisibleArr(N))
End If
Next N

''''''''''''''''''''''''''''''''
' Hide the INTRO sheet.
''''''''''''''''''''''''''''''''
ThisWorkbook.Sheets(C_INTRO_SHEETNAME).Visible = xlSheetVeryHidden

''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set the workbook protection back to what it was.
''''''''''''''''''''''''''''''''''''''''''''''''''''''
ThisWorkbook.Protect Password:=C_WORKBOOK_PASSWORD, _
structure:=HasProtectStructure, Windows:=HasProtectWindows

Exit Sub

ErrHandler:
ThisWorkbook.Worksheets(C_INTRO_SHEETNAME).Visible = xlSheetVisible

End Sub
___________________________________________________________________________________
_________________
'For an alternative technique, using formula calculations and defined
' names, to ensure that a workbook is opened with macros enabled, see
' the Ensuring Macros Are Enabled, Part 2 page.

'This page last updated: 21-July-2007

___________________________________________________________________________________
_________________

H="Remove all formulas in all worksheets (#noformulas)

'For presentation purposes. Since this will purposely destroy all


' formulas in a workbook ou would only want to run this on a copy of a
' live workbook.

Sub Remove_All_Formulas_In_All_Sheets 'No_formula_Macro()


'Goodnight 2000-10-27 programming -- Striping a workbook of formulas
Dim SH As Worksheet
For Each SH In Worksheets
SH.Activate
Application.ScreenUpdating = False
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:= False, Transpose:=False
Next
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

H="Excel VBA: Create a List of Hyperlinks to List all Excel Workbooks"

'Create a Hyperlinked List of Excel Workbook File Names

'With the use of Excel VBA Macro code we can create a list of
' Hyperlinked Excel Workbook names on any Excel Worksheet. The code
' below can be used on any version of Excel, 2000 or higher. The only
' changes needed are to the file paths used. The part of the code that
' reads: .Filename = "Book*.xls" has been commented out but can be
' uncommented if you wish to restrict the list to that of specific
' Excel Workbook name. Note also the code 'as is' restricts the list
' to only Excel Workbooks. However, this can be any of the File types
' listed below;

'MsoFileType can be one of these MsoFileType constants

msoFileTypeAllFiles
msoFileTypeBinders
msoFileTypeCalendarItem
msoFileTypeContactItem
msoFileTypeCustom
msoFileTypeDatabases
msoFileTypeDataConnectionFiles
msoFileTypeDesignerFiles
msoFileTypeDocumentImagingFiles
msoFileTypeExcelWorkbooks
msoFileTypeJournalItem
msoFileTypeMailItem
msoFileTypeNoteItem
msoFileTypeOfficeFiles
msoFileTypeOutlookItems
msoFileTypePhotoDrawFiles
msoFileTypePowerPointPresentations
msoFileTypeProjectFiles
msoFileTypePublisherFiles
msoFileTypeTaskItem
msoFileTypeTemplates
msoFileTypeVisioFiles
msoFileTypeWebPages
msoFileTypeWordDocuments

Ensure the active Worksheet at the time of running the code is clean so as to not
over write existing data.

Sub HyperlinkXLSFiles()

Dim lCount As Long

Application.ScreenUpdating = False

Application.DisplayAlerts = False

Application.EnableEvents = False

On Error Resume Next

With Application.FileSearch

.NewSearch

'Change path to suit

.LookIn = "C:\MyDocuments\Testings"
.FileType = msoFileTypeExcelWorkbooks

' .Filename = "Book*.xls"

If .Execute > 0 Then 'Workbooks in folder

For lCount = 1 To .FoundFiles.Count 'Loop through all.

ActiveSheet.Hyperlinks.Add Anchor:=Cells(lCount, 1), Address:=


_

.FoundFiles(lCount), TextToDisplay:= _

Replace(.FoundFiles(lCount), "C:\MyDocuments\Testings\", "")

Next lCount

End If

End With

On Error GoTo 0

Application.ScreenUpdating = True

Application.DisplayAlerts = True

Application.EnableEvents = True

End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

H="Timebombing A Workbook"

'This page describes how to limit the functionality of a workbook


' after a period of time.
'

'Introduction

'There may be circumstances in which you want to limit the


' functionality of a workbook after a specified period of time, such
' as distributing a demonstration or trial version of an application.
' Excel doesn't lend itself well to doing this. Nearly any limitation
' on a workbook can be circumvented by an experienced user. That said,
' there are a numbers thing you can do limit the usable life of a
' workbook, called time-bombing as workbook.

'Unfortunately, no VBA-based time-bombing method is foolproof. A


' skilled user can quite easily circumvent the time-bomb code and get
' full access to the workbook, even after it has expired. The code on
' this page also requires that the user has macros enabled. If macros
' are disabled, the code will not work. (See Ensuring Macros Are
' Enabled for code to force the user to enable macros.) All that said,
' the time-bomb methods presented here are probably "good enough".
' They will not prevent an experienced (and dishonest) user from
' circumventing the protection, but the code will work for the vast
' majority of Excel users. All protection mechanisms in Excel are
' really intended to prevent the user from accidentally changing a
' value or some code. The security just isn't strong enough to provide
' real protection of proprietary information or information or code
' with intellectual property value. For that level of security, you
' should be writing your code in Visual Basic 6 or VB.NET. See
' Creating A COM Add-In for details about creating a COM Add-In and
' Automation Add Ins A Function Libraries for details about creating
' an Automation Add-Ins.

'A quick note regarding security in Excel: Security of any sort in


' Excel is extremely weak. There are many password breakers available
' on the internet. I use PassWare's VBAKey and ExcelKey that can crack
' Excel and VBA Project passwords effortlessly, usually in a matter of
' seconds. In most cases, the password assigned to an object (a sheet,
' workbook, or VBA Project) isn't the only password that will succeed
' in opening the object. It is one of many mathematically related
' passwords, any one of which will work. For example, in some tests of
' VBAKey, VBAKey will return not the password that I actually used to
' protect the project, but a seemingly random string of characters
' that will pass successfully through the password validation logic.

'As I tell all of my commercial clients, password protection, or


' protection of any sort, should be viewed as a method to keep the
' honest user from accidentally changing or deleting something he
' shouldn't. The security is by no means sufficient to protect
' proprietary data or code or code with intellectual property value.
' The same goes for any sort of registry based key storage or
' settings. A skilled user can easily run RegEdit and see the values
' in the registry. The same hold true for macro based security. Not
' only can the VBA password be easily broken, but nearly all macro
' based security relies on macros being enabled in the first place and
' that the Application's EnableEvents setting is True. It is a
' one-liner to circumvent either of those two restrictions.
'The bottom line is that if you have valuable code and you need more
' than "honest person" security, then VBA is not sufficient. You
' should create a COM Add-In in VB6 or a Shared Add-In or an Excel
' Workbook in VB.NET and Visual Studio Tools For Office.

'All of the procedures desribed on this page use the constant:

Private Const C_NUM_DAYS_UNTIL_EXPIRATION = 30

'You should change the value of this constant to number of days after
' the first usage of the workbook that the workbook should be
' disabled. The value provided in the is 30 days. On the 31st day
' after the first time the workbook is opened, it will become
' unusable.

'You can download an example workbook here.


'TimeBomb With A Defined Name

'This procedure, TimeBombWithDefinedName, uses a hidden defined name


' to store the expiration date. The first time the workbook is opened,
' that defined name will not exist and will be created by the code.
' (Be sure that you delete this name when you are done with your own
' development work on the workbook.) When the defined name is created,
' it uses the C_NUM_DAYS_UNTIL_EXPIRATION constant to calculate the
' expiration date. When workbook is opened after the first time, the
' code reads the name ExpirationDate and tests that value against the
' current date.

Sub TimeBombWithDefinedName()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' TimeBombWithDefinedName
' This procedure uses a defined name to store this workbook's
' expiration date. If the expiration date has passed, a
' MsgBox is displayed and this workbook is closed.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ExpirationDate As String
Dim NameExists As Boolean

On Error Resume Next


ExpirationDate = Mid(ThisWorkbook.Names("ExpirationDate").Value, 2)
If Err.Number <> 0 Then
'''''''''''''''''''''''''''''''''''''''''''
' Name doesn't exist. Create it.
'''''''''''''''''''''''''''''''''''''''''''
NameExists = False
ExpirationDate = CStr(DateSerial(Year(Now), _
Month(Now), Day(Now) + C_NUM_DAYS_UNTIL_EXPIRATION))
ThisWorkbook.Names.Add Name:="ExpirationDate", _
RefersTo:=Format(ExpirationDate, "short date"), _
Visible:=False
Else
NameExists = True
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''
' If the today is past the expiration date, close the
' workbook. If the defined name didn't exist, we need
' to Save the workbook to save the newly created name.
''''''''''''''''''''''''''''''''''''''''''''''''''''''
If CDate(Now) > CDate(ExpirationDate) Then
MsgBox "This workbook trial period has expired.", vbOKOnly
ThisWorkbook.Close savechanges:=False
End If

End Sub
___________________________________________________________________________________
_________________

'TimeBomb With Suicide

'A more extreme version of timebombing code is to permanently delete


' the workbook once the expiration date has passed. I generally
' wouldn't recommend this approach, but it is certainly possible.

'CAUTION: This code will permanently delete (not Recycle) the workbook
' that contains the code. Once deleted, there is no way to get the
' workbook back. Be sure you that when you are testing you have
' another copy of the code.

'However you store and calculate the expiration date, you can use the
' code below to delete the workbook containing the code.

Sub CommintSuicide()
With ThisWorkbook
Application.DisplayAlerts = False
If .Path <> vbNullString Then
.ChangeFileAccess xlReadOnly
Kill .FullName
End If
ThisWorkbook.Close SaveChanges:=False
End With
End Sub
___________________________________________________________________________________
_________________

'TimeBomb To Read-Only

'This procedure, TimeBombMakeReadOnly, uses a defined name, just as


' the previous procedure did, but rather than closing the workbook, it
' makes the workbook read-only.

Sub TimeBombMakeReadOnly()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' TimeBombMakeReadOnly
' This procedure uses a defined name to store the expiration
' date and if the workbook has expired, makes the workbook
' read-only.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim ExpirationDate As String


Dim NameExists As Boolean

On Error Resume Next


ExpirationDate = Mid(ThisWorkbook.Names("ExpirationDate").Value, 2)
If Err.Number <> 0 Then
'''''''''''''''''''''''''''''''''''''''''''
' Name doesn't exist. Create it.
'''''''''''''''''''''''''''''''''''''''''''
ExpirationDate = CStr(DateSerial(Year(Now), _
Month(Now), Day(Now) + C_NUM_DAYS_UNTIL_EXPIRATION))
ThisWorkbook.Names.Add Name:="ExpirationDate", _
RefersTo:=Format(ExpirationDate, "short date"), _
Visible:=False
NameExists = False
Else
NameExists = True
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''
' If the today is past the expiration date, make the
' workbook read only. We need to Save the workbook
' to keep the newly created name intact.
''''''''''''''''''''''''''''''''''''''''''''''''''''''
If CDate(Now) >= CDate(ExpirationDate) Then
If NameExists = False Then
ThisWorkbook.Save
End If
ThisWorkbook.ChangeFileAccess xlReadOnly
End If

End Sub
___________________________________________________________________________________
_________________

'TimeBomb With Registry

'This procedure, TimeBombWithRegistry, stores the expiration date in


' the System Registry. To use this code, you must include the
' modRegistry code module, avaiable on the System Registry page, or
' use the RegistryWorx.dll available on the RegistryWorx page. If you
' use the modRegistry module, you will also need to include the
' modGetSystemErrorMessageText, available here. The modRegistry module
' and the modGetSystemErrorMessageText modules are included in the
' downloadable example workbook.

Sub TimeBombWithRegistry()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' TimeBombWithRegistry
' This procedure stores the expiration date in the system
' registry. Change C_REG_KEY to a registry key name that
' is used by your application.
'
' This procedure requires either the modRegistry module from
' www.cpearson.com/Excel/Registry.htm or
' www.cpearson.com/Excel/Registry.aspx
' or the RegistryWorx DLL from
' www.cpearson.com/Excel/RegistryWorx.aspx.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Const C_REG_KEY = "Software\Pearson\Test\Settings"


Dim KeyExists As Boolean
Dim ValueExists As Boolean
Dim ExpirationDate As Long
Dim B As Boolean
KeyExists = RegistryKeyExists(HKEY_CURRENT_USER, C_REG_KEY, False)
If KeyExists = True Then
'''''''''''''''''''''''''''''''''
' Key exists. Get the Value from
' the key.
'''''''''''''''''''''''''''''''''
ValueExists = RegistryValueExists(HKEY_CURRENT_USER, C_REG_KEY, "Expiration")
If ValueExists = True Then
'''''''''''''''''''''''''''''''''''''''''
' Value exists. It will be the
' expiration date.
'''''''''''''''''''''''''''''''''''''''''
ExpirationDate = RegistryGetValue(HKEY_CURRENT_USER, C_REG_KEY,
"Expiration")
Else
'''''''''''''''''''''''''''''''''''''''''
' Value doesn't exist. Set the expiration
' date and update the Registry.
'''''''''''''''''''''''''''''''''''''''''
ExpirationDate = DateSerial(Year(Now), Month(Now), _
Day(Now) + C_NUM_DAYS_UNTIL_EXPIRATION)
B = RegistryCreateValue(HKEY_CURRENT_USER, C_REG_KEY, "Expiration",
CLng(ExpirationDate))
If B = False Then
' error creating registry value
End If
End If
Else
''''''''''''''''''''''''''''''''''''''''
' Key doesn't exist. Set the expiration
' date and create the Key and Value.
''''''''''''''''''''''''''''''''''''''''
ExpirationDate = DateSerial(Year(Now), Month(Now), _
Day(Now) + C_NUM_DAYS_UNTIL_EXPIRATION)
B = RegistryCreateKey(HKEY_CURRENT_USER, C_REG_KEY)
If B = True Then
B = RegistryCreateValue(HKEY_CURRENT_USER, C_REG_KEY, "Expiration",
ExpirationDate)
If B = False Then
' error creating registry value
End If
Else
' error creating registry key
End If
End If
'''''''''''''''''''''''''''''''''''''''''''
' If Now is past the expiration date,
' close the workbook.
'''''''''''''''''''''''''''''''''''''''''''
If CLng(Now) > CLng(ExpirationDate) Then
ThisWorkbook.Close savechanges:=False
End If

End Sub
___________________________________________________________________________________
_________________

'Making The Code Run At Open

'Regardless of which procedure you use to limit usage of the workbook,


' you should call that procedure for the Workbook_Open event procedure
' in the ThisWorkbook code module:

Private Sub Workbook_Open()


TimeBombWithRegistry
End Sub
___________________________________________________________________________________
_________________

'Note that this will not work if the user has disabled VBA code or has
' set the Application.EnableEvents property to False.

'This page last updated: 11-Oct-2007


'
'Created by Chip Pearson at Pearson Software Consulting, LLC
'Email: chip@cpearson.com Before emailing me, please read this page.
'http://www.cpearson.com/excel/WorkbookTimeBomb.aspx
'Copyright � 1997 - 2012, Charles H. Pearson

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/]
[/][/][/][/][/][/
\
+\_\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=
-\=-\=-_\=-\=-\-
}?}?}/}/}/]/}/]/]?}/}/}/}?}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}
?]/}?]/}?]/}?]/}?
><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)
(><)(><)(><)(><)(><
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

H="Option Explicit- Totally Gettin stuff. "

Option Explicit
'-- David McRitchie http://www.mvps.org/dmcritchie/excel/formula.htm
'-- http://www.mvps.org/dmcritchie/excel/code/formula.txt

'-- Directions to install VBA code can be found at


' http://www.mvps.org/dmcritchie/excel/getstarted.htm#modulename
' Install as a new Module {Insert, New Module) (warning not as a class module)
' with name "McRitchie_Formula" by changing name of Module nnn by selecting
' Module nnn if not already selected then get to View, Properties using
' F4 {View, Properties Window} and change the module name.
'
' Also of interest see http://www.mvps.org/dmcritchie/excel/rightclick.htm
' to add GetFormula_sub to context (right-click) menu.
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="GetFormula"

Monday, April 30, 2012 - 01:07 AM

Function GetFormula(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Application.Volatile = True
GetFormula = cell.Formula
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="GetFormulaD"

Monday, April 30, 2012 - 01:08 AM

Function GetFormulaD(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Application.Volatile = True
GetFormulaD = cell.Address(0, 0) & ": " & cell.Formula
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="Function GetFormat"

Monday, April 30, 2012 - 01:09 AM

Function GetFormat(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
' Application.Volatile = True
On Error Resume Next
GetFormat = ""
GetFormat = cell.NumberFormat
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="GetFormatD"

Monday, April 30, 2012 - 01:09 AM

Function GetFormatD(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
' Application.Volatile = True
On Error Resume Next
GetFormatD = ""
GetFormatD = cell.Address(0, 0) & ": " & cell.NumberFormat
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="GetFormulaI"

Monday, April 30, 2012 - 01:10 AM

Function GetFormulaI(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Application.Volatile = True
If VarType(cell) = 8 And Not cell.HasFormula Then
GetFormulaI = "'" & cell.Formula
Else
GetFormulaI = cell.Formula
End If
If cell.HasArray Then _
GetFormulaI = "{" & cell.Formula & "}"
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
H=" GetFormulaID(cell As Ran"

Monday, April 30, 2012 - 01:10 AM

Function GetFormulaID(cell As Range) As String


'Application.Volatile = True
Dim GetFormulaI As String
If VarType(cell) = 8 And Not cell.HasFormula Then
GetFormulaI = "'" & cell.Formula
Else
GetFormulaI = cell.Formula
End If
If cell.HasArray Then _
GetFormulaI = "{" & cell.Formula & "}"
GetFormulaID = cell.Address(0, 0) & ": " & GetFormulaI
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="tFormulaX(cell As Ra"

Monday, April 30, 2012 - 01:10 AM

Function GetFormulaX(cell As Range) As String


'-- to be used in another formula =indirect(xx) + insdirect(yy)
'Application.Volatile = True
If IsEmpty(cell) Then
GetFormulaX = """"""
ElseIf VarType(cell) = 8 And Not cell.HasFormula Then
If Left(cell, 1) = "'" Then
GetFormulaX = """" & Mid(cell, 2) & """"
Else
GetFormulaX = """" & cell & """"
End If
ElseIf cell.HasFormula Then
GetFormulaX = Mid(cell.Formula, 2)
Else
GetFormulaX = cell.Formula
End If
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="tFontName(cell As Ran"

Monday, April 30, 2012 - 01:11 AM

Function getFontName(cell As Range) As String


getFontName = cell.Font.Name 'D.McR formula.htm
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H=" GetText(cell A"

Monday, April 30, 2012 - 01:11 AM

Function GetText(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
' Application.Volatile = True
On Error Resume Next
GetText = cell.Text
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="HasFormula(cell)"

Monday, April 30, 2012 - 01:11 AM

Function HasFormula(cell)
'created using a suggestion by Nick Manton nickm@sri.com
' http://www.mvps.org/dmcritchie/excel/formula.htm
HasFormula = cell.HasFormula
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H=" ShowFormula(cell As Ran"

Monday, April 30, 2012 - 01:12 AM

Function ShowFormula(cell As Range) As String


Application.Volatile
If cell.HasFormula Then ShowFormula = cell.Formula
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H=" FontStyle(cell As Range) "

Monday, April 30, 2012 - 01:12 AM

Function FontStyle(cell As Range) As String


'Won't change value until some value on sheet changes
Application.Volatile
FontStyle = cell.Font.FontStyle
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="ondFormula(myCell As R"

Monday, April 30, 2012 - 01:12 AM

Function CondFormula(myCell As Range, Optional cond As Long = 1) As String


'Bernie Deitrick programming 2000-02-18, modified D.McR 2001-08-07
Application.Volatile
CondFormula = ""
On Error Resume Next
CondFormula = myCell.FormatConditions(cond).Formula1
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
___________!_____________!______________!__________________!__________!______!
____________!________!
___________!______________!_____________!_________________!__________!________!
____________!________!
__________!______________!_______________!______________!___________!_________!
__________!_________!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="Sub FormulaBox()"

Monday, April 30, 2012 - 01:26 AM

Sub FormulaBox()
'David McRitchie 1998-08-12 1999-08-17
' http://www.mvps.org/dmcritchie/excel/formula.htm
'Place material into MsgBox [ctrl+n]
'Will process ranges of one or more columns
'Application.ScreenUpdating = False
Dim MsgBoxx As String
Dim ix As Long
Dim vGetFormulaI As String, xyx As String
MsgBoxx = "First Character of " _
& Selection.Item(ix).Address(0, 0) & " is """ _
& Left(ActiveCell.Value, 1) & """ =CHR(" _
& Right("0000" & Asc(ActiveCell.Value), 4) & ") or Hex=x'" _
& Hex(Asc(ActiveCell.Value)) & "'" & Chr(10) _
& "Last Character is """ & Right(ActiveCell.Value, 1) _
& """ =CHR(" _
& Right("0000" & Asc(Right(ActiveCell.Value, 1)), 4) & ") or Hex=x'" _
& Hex(Asc(Right(ActiveCell.Value, 1))) & "'" & Chr(10) _
& ActiveCell.Font.Name & " " & ActiveCell.Font.Size _
& " " & ActiveCell.Font.FontStyle _
& ", color: " & ActiveCell.Font.ColorIndex _
& " interior: " & ActiveCell.Interior.ColorIndex _
& Chr(10) & Chr(10)

For ix = 1 To Selection.Count
'Selection.Item(ix).NoteText _ ...
vGetFormulaI = ""
If VarType(Selection.Item(ix)) = 8 Then
vGetFormulaI = "'" & Selection.Item(ix).Formula
Else
vGetFormulaI = Selection.Item(ix).Formula
End If
If Selection.Item(ix).HasArray Then _
vGetFormulaI = "{" & Selection.Item(ix).Formula & "}"

'include below if VarType wanted -- don't include for distribution


' & " " & VarType(Selection.Item(ix)) _ ..
MsgBoxx = MsgBoxx _
& Selection.Item(ix).Address(0, 0) _
& ": " & vGetFormulaI _
& Chr(10) & " " & Selection.Item(ix).NumberFormat & Chr(10)

Next
MsgBoxx = MsgBoxx & Chr(10) & "***" _
& Chr(10) & _
LCase(ActiveWorkbook.FullName) & " " & ActiveSheet.Name
'to verify you've seen everything
xyx = MsgBox(MsgBoxx, , _
"FormulaBox: Formula & Format & Text for " _
& Selection.Count & " selected cells")
'Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="Sub FormulaSheet()"

Monday, April 30, 2012 - 01:27 AM

Sub FormulaSheet()
'Print information for each non empty cell DMcRitchie 2001-04-30
'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Also see John Walkenbach -- Tip 37 which is formulas only

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim irow As Long, cell As Range
Dim oSheet As Worksheet, nSheet As Worksheet
Dim oCells As Range
irow = 1
Set oSheet = ActiveSheet
Set nSheet = ActiveWorkbook.Worksheets.Add
nSheet.Name = oSheet.Name & " content at " _
& Format(Now(), "hhmss")
nSheet.Cells(1, 1) = "Cell"
nSheet.Cells(1, 2) = "Text"
nSheet.Cells(1, 3) = "Value"
nSheet.Cells(1, 4) = "Formula"
nSheet.Cells(1, 5) = "NumberFormat"

For Each cell In oSheet.UsedRange


If Not IsEmpty(cell) Then
irow = irow + 1
Cells(irow, 1).Value = cell.Address(0, 0)
Cells(irow, 2).Value = "'" & cell.Text
Cells(irow, 3).Value = cell.Value
Cells(irow, 4).Value = "'" & cell.Formula
Cells(irow, 5).Value = "'" & cell.NumberFormat
End If
Next cell
Columns("A:F").EntireColumn.AutoFit
Rows("1:1").Font.Bold = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="Function UseFormula(cell)"

Monday, April 30, 2012 - 01:27 AM

Function UseFormula(cell)
'David McRitchie Jul 20, 1998 if this is valid will be
'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
UseFormula = Application.Evaluate(cell.Formula)
'If "'" <> Left(cell.formula, 1) Then UseFormula = "'" & cell.formula
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="eFormula2(cell As Ran"

Monday, April 30, 2012 - 01:27 AM

Function UseFormula2(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'UseFormula Jul 20, 1998, UseFormula2 Jun 13, 2000
'Application.Volatile = True -- DO NOT DO THIS
'GetFormula = cell.Formula
If Trim(cell.Value) = "" Then
UseFormula2 = ""
Exit Function
ElseIf Left(cell.Value, 1) = "=" Then
UseFormula2 = Application.Evaluate(cell.Formula)
Exit Function
Else
UseFormula2 = "'#bad formula"
End If
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="UseSameAs(cell As Ran"

Monday, April 30, 2012 - 01:27 AM


Function UseSameAs(cell As Range)
'-- Use the same Formula as used in the referenced cell
'-- http://mvps.org/dmcritchie/excel/formula.htm#usesameas 2005-09-03 .excel
Application.Volatile
If cell.HasFormula Then
UseSameAs = Application.Caller.Parent.Evaluate(cell.Formula)
Else '-- needed if constant looks like a cell address
UseSameAs = cell.Value
End If
End Function
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="ISBOLD(cell As Range) A"

Monday, April 30, 2012 - 01:28 AM

Function ISBOLD(cell As Range) As Boolean


If cell.Font.Bold Then ISBOLD = True
End Function

'-- The following macros have been moved to McRitchie_insrtrow (insrtrow.txt)


'-- InsertRowsAndFillFormulas(Optional vRows As Long = 0)
'-- InsertBlankRows()
'-- InsertBlankRowBeforeLast()
'-- Guarantee2RowsAfterA_values()
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H=" WhereAmI()"

Monday, April 30, 2012 - 01:28 AM

Sub WhereAmI()
'D.McRitchie, pathname.htm, excel.misc 1999-07-30
MsgBox ActiveWorkbook.FullName & Chr(10) & _
"Microsoft Excel is using " & Application.OperatingSystem
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

Sub Euro_Format()
Selection.NumberFormat = _
"_(�* #,##0.00_);_(�* (#,##0.00);_(�* "" - ""???_);_(@_)"
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
H="n showAlign(cell As Range)"

Monday, April 30, 2012 - 01:29 AM

Function showAlign(cell As Range) As String


'David McRitchie, 2004-09-15
' based on http://www.mvps.com/dmcritchie/excel/code/xl2htmlx.txt
Dim ca As String
If Trim(Replace(cell.Text, Chr(160), "")) = "" Then
ca = "N/A"
ElseIf cell.HorizontalAlignment = -4138 Then
ca = "Left"
ElseIf cell.HorizontalAlignment = -4108 Then
ca = "Center"
ElseIf cell.HorizontalAlignment = -4131 Then
ca = "Left"
ElseIf cell.HorizontalAlignment = -4152 Then
ca = "Right"
ElseIf IsNumeric(cell) Then
ca = "Right"
Else
ca = "Left"
End If '-4138 left, -4108 center, -4152 right, HTML default left
showAlign = ca
End Function

_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

H="Placing Displayed Text into Cell Comments (#cctext)"

'The following does same for displayed text (constants and formulas).
' It is practical only for testing things that need a lot of comments
' generated. Such test data can be created with MarkCells and then
' run the following macro. Note use of Del key does not affect cell
' comments.

Sub TextIntoComments()
Dim cell As Range
Selection.ClearComments
For Each cell In Intersect(Selection, ActiveSheet.UsedRange)
If Trim(cell.Text) <> "" Then
cell.AddComment cell.Text
cell.Comment.Visible = False
cell.Comment.Shape.TextFrame.AutoSize = True
End If
Next cell
End Sub
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

H="Copy Comments from All Sheets to Another Worksheet"

'The following macro will add a sheet to the workbook, with a list of
' Excel comments from all sheets in the workbook, including the sheet
' name, cell address, and cell name, if any.

Sub ShowCommentsAllSheets()
'modified from code
'posted by Dave Peterson 2003-05-16
Application.ScreenUpdating = False

Dim commrange As Range


Dim mycell As Range
Dim ws As Worksheet
Dim newwks As Worksheet
Dim i As Long

Set newwks = Worksheets.Add

newwks.Range("A1:E1").Value = _
Array("Sheet", "Address", "Name", "Value", "Comment")

For Each ws In ActiveWorkbook.Worksheets


On Error Resume Next
Set commrange = ws.Cells.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If commrange Is Nothing Then


'do nothing
Else

i = newwks.Cells(Rows.Count, 1).End(xlUp).Row
For Each mycell In commrange
With newwks
i = i + 1
On Error Resume Next
.Cells(i, 1).Value = ws.Name
.Cells(i, 2).Value = mycell.Address
.Cells(i, 3).Value = mycell.Name.Name
.Cells(i, 4).Value = mycell.Value
.Cells(i, 5).Value = mycell.Comment.text
End With
Next mycell
End If
Set commrange = Nothing
Next ws

'format cells for no wrapping, remove line break


newwks.Cells.WrapText = False
newwks.Columns("E:E").Replace What:=Chr(10), _
Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

Application.ScreenUpdating = True

End Sub
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/]
[/][/][/][/][/][/
\
+\_\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=
-\=-\=-_\=-\=-\-
}?}?}/}/}/]/}/]/]?}/}/}/}?}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}
?]/}?]/}?]/}?]/}?
><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)
(><)(><)(><)(><)(><
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
H="Insert a Plain Comment"

'To insert a comment with no User Name, use the following macro.
'Note: Because the macro contains a SendKeys command, it should be run
' with the worksheet active, not Visual Basic Explorer.

Sub CommentAddOrEdit()
'adds new plain text comment or positions
'cursor at end of existing comment text
'www.contextures.com\xlcomments03.html
Dim cmt As Comment
Set cmt = ActiveCell.Comment
If cmt Is Nothing Then
ActiveCell.AddComment text:=""
End If
SendKeys "%ie~"
End Sub
___________________________________________________________________________________
_________________

'To avoid use of the SendKeys command, you can use the following
' variation, which leaves the Excel comments visible. After running
' the macro, the comment shape is selected. Start typing, and the text
' will be added to the comment box, or to the end of the existing
' comment text.

Sub CommentAddOrEdit()
'method suggested by Jon Peltier 2006-03-04
'adds new plain text comment or adds text
'at end of existing comment text
Dim cmt As Comment
Set cmt = ActiveCell.Comment
If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
cmt.text text:=""
End If

'type to add comment text to selected shape


cmt.Visible = True
cmt.Shape.Select

End Sub
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*(0&^**=/^*&^*&^*(0&^*&^*&^*&^*&^*&^*&^*&^*&*=-=/*-
=^*&^*&^*&^*&^*&^*&^*&^=/**&^*&^*&^*&^*&^*&^*&^
=_)(_)(_)(_-*/)(_(0)(_)((0_)(_)(_)-*=(0/(_)(_)(_)(_)(/=_*)(_)(_)(_)(_)=(-_)(_)
(_/==)(_)(_)(_)(_)(_)(_)(_*=/)(_)(_)(_)(_)(_)(_(0
!^/*-/!^/!^/!^/!(0^/--*/!^/!^/!(0^/!^/(0!^/!^/!-=/^/!^/=!*^/!^//=!*^/!*-=^-*/!^/!
^/!^/!^/!^-*=/!^/!^/!^/!^/!^/!^/!^/=-*/!^/!^/!^/!^/!^
(0!^?>/=*(0<!^?>*<!^-?-*/>*<(0!^(0?>*<!^?>*-=*-*=<!^?>*<!*==^?>*<!^?>*<!^?>*<!=-
=//-^?>*<!^?>*=<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>
/][/(0][(0/][/]/*-[/][/][/][/][/][/](0[/-*/][/][/][(0/][-*=/*-][/][/][/][/--*=*-=]
[/][/*]=/[/][/][/][/][/][/][/][/][/][-=-=-=///][/][/][//*/=
\+\(0_\=(0-\=-=/\=-\=-\(0=-\=-\=--**/=/-\=-\=-\-=/=-*=/-\=-\=-\=--*=\=-\=-
*/=\=-\=-\=-\=-\=-\=-\=*-=-\=-*-*/=\=-(0\=*/=*-\=-\=-\=-\=-_\=-\=-\-
(0}?}?}/}/}/(0]/}/]*-/(0]?}/}/}/}?}*=/?]/}?-**-=//]/}?]/}?]/}?]/}?]/}?-*=]/}?]/}?
*]/}?]/}?]/}?]/}?]/}?]/}?**=/-=]/}?]/}?]/}(0?]/}?(0
><)(><)(><((00)(><)(><)(=-><)(>*=<)(-*/><)(><)(><)(><)(>-*=<)(><)/=(><)(><)(><)(*-
=><)(>-=/<)(><)(><)(><)(0(>(0<(0)(><)(><)(><)(><
|+__|+_(0_|+__|(0+__|+=*__|+_*=-_|+__|+_-*/_|+__|+__|+___|+__-*|-*=+_*=_-*_|+__/*_|
+____|+__-=/|+__|+(0___|+___|+_||+(0__|+__|+__|+_
{}!{}!(0{}!{}!{}!{}!={/(0=*/}!{}*=/-!{}!{}!{}!{}!{}!{}!{}!{}-*/!{}!{}!(0{}!{}!{}!
{}!{}!{}!{}!{*-=}!/={=/}!{}!{}!{}!{}!{}!{}!-=/{}!(0
__(0_________-/-*/__*(0=/-__=-_____(0_______________-*/___________________-
*=________________-*=______________________________
|+__|+_*-/=_|+-*=_-_|+__|+(0_*/_|(0+__|+__|+__|+__|+__|-*/+___|+__|+___|+___|+_-
*=___|+__|+__|+___==/-/|+___|+_||+__|+__|+__|+_
_)(_)*=/(_)*/=(_)(_)(_)(_)(_)=(_(0)(_)(_)(_)(_)(_)(_)(_)(_)-*/(_)(_)(_)(_)(_)(_)(_)
(_)(_*-=)(_)(_)(_)(_)(_)(_)(*/=_)(_
*&*^*&^*&^*&^*&^*&^*&/=^*&^*&^*&^*&^*&^*&^*&^*-*/&^*&^*&^*&^*&^*&^*&^*&-
*^*&^*&^*&^*&^*&^*&^-*=/*&^*&^*&^*&^
-/*=

H="Replace Old Name in Excel Comments"

'If a previous user inserted comments, their name may appear at the
' top of the comment. Their name may also appear in the Status Bar,
' when you hover over the cell that contains a comment. The following
' macro will replace the old name with a new name.

Sub ChangeCommentName()
'replaces old names in Excel comments
'deletes and reinserts Excel comments
' so new name appears in status bar
'www.contextures.com\xlcomments03.html
Dim ws As Worksheet
Dim cmt As Comment
Dim strOld As String
Dim strNew As String
Dim strComment As String
strNew = "New Name"
strOld = "Old Name"
Application.UserName = strNew
For Each ws In ActiveWorkbook.Worksheets
For Each cmt In ws.Comments
strComment = Replace(cmt.text, strOld, strNew)
cmt.Delete
cmt.Parent.AddComment text:=strComment
Next cmt
Next ws

End Sub
___________________________________________________________________________________
_________________

\
+\_\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=
-\=-\=-_\=-\=-\-
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)
(><)(><)(><)(><)(><
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
}?}?}/}/}/]/}/]/]?}/}/}/}?}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}
?]/}?]/}?]/}?]/}?
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/]
[/][/][/][/][/][/
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

H="Insert a Formatted Comment"

'To insert Excel comments with no User Name, formatted in Times New
' Roman font, use the following macro:

Sub CommentAddOrEditTNR()
'adds TimesNewRoman comment or positions
'cursor at end of existing comment text
'www.contextures.com\xlcomments03.html
Dim cmt As Comment
Set cmt = ActiveCell.Comment
If cmt Is Nothing Then
ActiveCell.AddComment text:=""
Set cmt = ActiveCell.Comment
With cmt.Shape.TextFrame.Characters.Font
.Name = "Times New Roman"
.Size = 11
.Bold = False
.ColorIndex = 0
End With
End If
SendKeys "%ie~"
End Sub
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/]
[/][/][/][/][/][/
\
+\_\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=
-\=-\=-_\=-\=-\-
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
}?}?}/}/}/]/}/]/]?}/}/}/}?}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}
?]/}?]/}?]/}?]/}?
><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)
(><)(><)(><)(><)(><
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

H="Insert a Colour Formatted Comment"

'To insert a comment with no User Name, formatted with red text in the
' first line, blue text in the second line, and bold text after the
' colons, use the following macro:

Sub CommentTextFormatColour()
'adds comment then formats font colour and adds bold
'www.contextures.com\xlcomments03.html
Dim cmt As Comment
Dim str1 As String
Dim str2 As String
Dim lBreak As Long
Dim lNum1 As Long
Dim lNum2 As Long
Dim lNumLen As Long
Dim strFind As String
On Error Resume Next

str1 = "John: 20 Eggs"


str2 = "Simon: 50 Eggs"
strFind = ":"
lNumLen = 3

Set cmt = ActiveCell.Comment


If cmt Is Nothing Then
ActiveCell.AddComment _
text:=str1 & Chr(10) & str2
Set cmt = ActiveCell.Comment
End If

'find the line break and markers


lBreak = InStr(1, cmt.text, Chr(10))
lNum1 = InStr(1, cmt.text, strFind) + 1
lNum2 = InStr(lBreak, cmt.text, strFind) + 1

'format the lines of text


With cmt.Shape.TextFrame
.Characters(1, lBreak).Font.ColorIndex = 3
.Characters(lBreak + 1, Len(cmt.text)).Font.ColorIndex = 5
End With
'add bold to numbers that follow colon
If lNum1 > 0 Then
With cmt.Shape.TextFrame
.Characters.Font.Bold = False
.Characters(lNum1, lNumLen).Font.Bold = True
.Characters(lNum2, lNumLen).Font.Bold = True
End With
End If

SendKeys "%ie~"
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^
)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)
(*!)(*!)(*!)(*!)(*!)(*!)(*!)(*!)(*!)(*!)(*!)(*

H="Insert Excel Comments with Date and Time "

'To insert Excel comments with the current date and time, or append
' the current date and time to an existing comment, use the following
' macro:

Sub CommentDateTimeAdd()
'adds Excel comments with date and time,
' positions cursor at end of comment text
'www.contextures.com\xlcomments03.html

Dim strDate As String


Dim cmt As Comment

strDate = "dd-mmm-yy hh:mm:ss"


Set cmt = ActiveCell.Comment

If cmt Is Nothing Then


Set cmt = ActiveCell.AddComment
cmt.text text:=Format(Now, strDate) & Chr(10)
Else
cmt.text text:=cmt.text & Chr(10) _
& Format(Now, strDate) & Chr(10)
End If

With cmt.Shape.TextFrame
.Characters.Font.Bold = False
End With

SendKeys "%ie~"

End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Resize Excel Comments "

'If Excel comments have changed size, you can reset them using the
' following code. The first macro resizes all comments on the active
' sheet, and the second macro resizes all comments in the selected
' range.

Resize all comments on the active sheet


Sub Comments_AutoSize()
'posted by Dana DeLouis 2000-09-16

Dim MyComments As Comment


Dim lArea As Long
For Each MyComments In ActiveSheet.Comments
With MyComments
.Shape.TextFrame.AutoSize = True
If .Shape.Width > 300 Then
lArea = .Shape.Width * .Shape.Height
.Shape.Width = 200
' An adjustment factor of 1.1 seems to work ok.
.Shape.Height = (lArea / 200) * 1.1
End If
End With
Next ' comment
End Sub
___________________________________________________________________________________
_________________

Resize all comments in the selected area


Sub ResizeCommentsInSelection()
'Posted by Dave Peterson 2002-02-25
Dim mycell As Range
Dim myRng As Range
Dim lArea As Long

Set myRng = Selection

For Each mycell In myRng.Cells


If Not (mycell.Comment Is Nothing) Then
With mycell.Comment
.Shape.TextFrame.AutoSize = True
If .Shape.Width > 300 Then
lArea = .Shape.Width * .Shape.Height
.Shape.Width = 200
.Shape.Height = (lArea / 200) * 1.2
End If
End With
End If
Next mycell
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Copy Comment Text to Adjacent Cell "

'The following macro will copy comment text to the cell to the right,
' if that cell is empty.
Sub ShowCommentsNextCell()
'based on code posted by Dave Peterson 2003-05-16
Application.ScreenUpdating = False

Dim commrange As Range


Dim mycell As Range
Dim curwks As Worksheet

Set curwks = ActiveSheet

On Error Resume Next


Set commrange = curwks.Cells _
.SpecialCells(xlCellTypeComments)
On Error GoTo 0
If commrange Is Nothing Then
MsgBox "no comments found"
Exit Sub
End If

For Each mycell In commrange


If mycell.Offset(0, 1).Value = "" Then
mycell.Offset(0, 1).Value = mycell.Comment.Text
End If
Next mycell

Application.ScreenUpdating = True

End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Copy Comments to Another Worksheet "

'The following macro will add a sheet to the workbook, with a list of
' comments, including the cell address, and cell name, if any.
Sub showcomments()
'posted by Dave Peterson 2003-05-16
Application.ScreenUpdating = False

Dim commrange As Range


Dim mycell As Range
Dim curwks As Worksheet
Dim newwks As Worksheet
Dim i As Long

Set curwks = ActiveSheet

On Error Resume Next


Set commrange = curwks.Cells _
.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If commrange Is Nothing Then


MsgBox "no comments found"
Exit Sub
End If

Set newwks = Worksheets.Add

newwks.Range("A1:D1").Value = _
Array("Address", "Name", "Value", "Comment")

i = 1
For Each mycell In commrange
With newwks
i = i + 1
On Error Resume Next
.Cells(i, 1).Value = mycell.Address
.Cells(i, 2).Value = mycell.Name.Name
.Cells(i, 3).Value = mycell.Value
.Cells(i, 4).Value = mycell.Comment.Text
End With
Next mycell

Application.ScreenUpdating = True

End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Deleting Shapes (#delete)"

' Dave Peterson showed us that you don't need a loop at all
' just two lines of code on the inside. (misc 2001-11-12)
Sub delShapesOnSht()
'Dave Peterson, misc 2001-11-12, no loop required
If ActiveSheet.Shapes.Count = 0 Then
MsgBox "No Shapes on page for deletion"
Exit Sub
End If
ActiveSheet.Shapes.SelectAll '*** warning DELETE all Shapes
Selection.Delete
End Sub
___________________________________________________________________________________
_________________
'' Dave Peterson provided another example in programming 2001-11-13 '
' to delete shapes with upper left corner within a selection range. '
' -- had -- ActiveSheet.Range("a37:o50")) Is Nothing Then
Sub delShapesSel()
'Delete shapes within selection range,
' Dave Peterson, programming, 2001-11-13
Dim myshape As Shape
For Each myshape In ActiveSheet.Shapes
If Intersect(myshape.TopLeftCell, _
Selection) Is Nothing Then
'do nothing
Else
myshape.Delete
End If
Next myshape
End Sub
___________________________________________________________________________________
_________________
'Missed the specific range in the above, it would be better to use
' Selection. instead of ActivesSheet.Range("a37:o50") -- one person
' used BottomRightCell instead of TopLeftCell due to the way that
' multiple shapes hit one cell. Modify to suit your needs. You can
' manually select all objects on a sheet regardless of what cells are
' selected with Edit, GoTo (Ctrl+G), Special, Objects.
Sub selShapesOnSht()
Dim shp As Shape
For Each shp In ActiveWorkbook.ActiveSheet.Shapes
ans = MsgBox("DELETE Shape" & Chr(10) & shp.Name & " " _
& shp.TopLeftCell.Address & Chr(10) & " -- " _
& shp.AlternativeText, vbYesNoCancel + vbDefaultButton2)
If ans = 2 Then
shp.Select 'Select shape and exit
Exit Sub
End If
If ans = 6 Then shp.Delete 'Delete the shape
Next shp
End Sub
___________________________________________________________________________________
_________________
Code for Particular Shapes:
If sp.AutoShapeType = msoShapeRectangle Then shp.Delete
If sp.AutoShapeType = msoShapeTriangle Then shp.Delete

Code to delete all Rectangular shapes on a sheet


'Since you can't collectively select them as a group of rectangles you
' have to select all of the shapes and then check them one by one. If
' there are no shapes then no shapes are tested.
Sub delAllRectangularShapesOnSht()
Dim shp As Shape
For Each shp In ActiveWorkbook.ActiveSheet.Shapes
'check shape code for Particular Shapes:
If shp.AutoShapeType = msoShapeRectangle Then shp.Delete
Next shp
End Sub
___________________________________________________________________________________
_________________
Code to find out who called a macro attached to a shape:
msgbox "This macro was called by: " & _
ActiveSheet.Shapes(Application.Caller).Name 'returns string
'To Manually create your own selection of shapes
'A suggestion from Debra Dalgleish: From customize, choose Commands
' (tab), Drawing (left side), Select Multiple Objects (right side) and
' drag to the drawing toolbar. I only keep the drawing icon on my
' toolbar and use it to brigng up the actual drawing toolbar when
' needed. [Debra Dalgleish, 2006-05-24]

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Option Explicit, buildtocstuff (Massive; to be clarified)"

Private Declare Function timeGetTime Lib "winmm.dll" () As Long


'Not all have been tested for use with Option Explicit
'Documented in http://www.mvps.org/dmcritchie/excel/buildtoc.htm
'Coding: http://www.mvps.org/dmcritchie/excel/code/buildtoc.txt
'Coding: http://www.mvps.org/dmcritchie/excel/code/gotostuff.txt
'My Excel Macros: http://www.mvps.org/dmcritchie/excel/excel.htm
'Separate coding for ListFunctionsAndSubs can be found at
' http://www.mvps.org/dmcritchie/excel/code/listfsubs.txt

'EnumerateSheets - list of sheets from active cell down, uses two columns
'For reordering sheets, I prefer Jeff Web's "ReOrderSheets"

'ReOrderSheets - reorders sheets within Type


' Types: Worksheet, Chart, Module, Dialogsheet
'SortSheets - reorders only Worksheets
'SortALLSheets - reorders ALL sheets, regardless of type

Sub DelHyperLinks()
Selection.Hyperlinks.Delete
End Sub
___________________________________________________________________________________
_________________
Sub delHyperLinksAndText()
'j.Walkenbach version 2000-11-13
'warning clears associated: value, hyperlink, tooltip
Dim hl As Variant
For Each hl In ActiveSheet.Hyperlinks
hl.Parent.Clear
Next hl
End Sub
___________________________________________________________________________________
_________________
Sub RemoveScreenTips()
'David McRitchie, misc, 2003-04-08, misc
Dim cell As Range
For Each cell In Intersect(Selection, ActiveSheet.UsedRange)
On Error Resume Next
cell.Hyperlinks(1).ScreenTip = ""
Next cell
End Sub
___________________________________________________________________________________
_________________
Sub DeleteThisSheet()
Dim ans As Variant
Dim saveTrue As Variant
Dim SheetCodeLines As Long
'--requires ref. to the MS VBA Extensibility' library
SheetCodeLines = ActiveWorkbook.VBProject.VBComponents _
(ActiveSheet.CodeName).CodeModule.CountOfLines
If SheetCodeLines > 2 Then
MsgBox ActiveSheet.Name & " -- has " & _
SheetCodeLines & " lines of code (not deleted) "
'-- want to open the sheet code here ---

ElseIf Left(ActiveSheet.Name, 5) = "Sheet" _


Or Application.WorksheetFunction.CountA(ActiveSheet.Cells) = 0 Then
Application.DisplayAlerts = False
ActiveSheet.Delete
'tflush_wav
Application.DisplayAlerts = True
Else
Application.DisplayAlerts = True
ActiveSheet.Delete
End If
End Sub
___________________________________________________________________________________
_________________
Sub Delete_EmptySheets()
Dim sh As Worksheet 'Ron de Bruin, programming, 2002-12-28
'On Error Resume Next 'possibility of all sheets blank
For Each sh In ThisWorkbook.Worksheets
If Application.WorksheetFunction.CountA(sh.Cells) = 0 Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End If
Next
'On Error goto 0 'Excel must have one sheet/workbook
End Sub
___________________________________________________________________________________
_________________
Sub SelectHyperlinks()
'D.McRitchie 2001-01-24 buildtoc.htm
Dim hl As Variant
Dim rng1 As String
For Each hl In ActiveSheet.Hyperlinks
rng1 = rng1 & "," & hl.Parent.Address(0, 0)
Next hl
If rng1 = "" Then
MsgBox "No Hyperlinks found in Sheet, so none in selection"
Exit Sub
End If
rng1 = Right(rng1, Len(rng1) - 1)
On Error Resume Next
Intersect(Selection, Range(rng1)).Select
If Err.Description = "" Then Exit Sub
MsgBox "Change your initial selection" & Chr(10) & _
"there are hyperlinks, but none in you initial selection" _
& Chr(10) & Err.number & " " & Err.Description
End Sub
___________________________________________________________________________________
_________________
Sub ConvertHyperlinks()
'David McRitchie, misc, 2000-01-17, misc
'http://www.mvps.org/dmcritchie/excel/buildtoc.htm
Dim cell As Range
Dim HyperlinkAddress As String, hyperlinkformula As String
For Each cell In Selection
On Error GoTo skipHyper
HyperlinkAddress = cell.Hyperlinks(1).Address
On Error GoTo 0
If HyperlinkAddress = "" Then GoTo skipHyper
hyperlinkformula = cell.Formula
If Left(hyperlinkformula, 1) = "=" Then
hyperlinkformula = Right(hyperlinkformula, Len(hyperlinkformula) - 1)
Else
hyperlinkformula = Replace(hyperlinkformula, """", """""")
hyperlinkformula = """" & hyperlinkformula & """"
End If
cell.Formula = "=HYPERLINK(""" & HyperlinkAddress & _
"""," & hyperlinkformula & ")"
skipHyper: On Error GoTo 0
Next cell
On Error GoTo 0
Selection.Hyperlinks.Delete
For Each cell In Selection
cell.Formula = cell.Formula
Next cell
End Sub
___________________________________________________________________________________
_________________

Sub MakeHyperlinks()
Dim cell As Range
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
With Worksheets(1)
.Hyperlinks.Add Anchor:=cell, _
Address:=cell.Value, _
ScreenTip:=cell.Value, _
TextToDisplay:=cell.Value
End With
Next cell
End Sub
___________________________________________________________________________________
_________________
Sub MakeHyperlinkTo_archiveorg()
Dim cell As Range, nCell As String
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
' If LCase(Left(Cell.Value, 7)) <> "http://" Then Exit Sub
nCell = "http://web.archive.org/web/*/"
On Error Resume Next
cell.Offset(0, 2) = "aa"
cell.Offset(0, 2).Formula = "=HYPERLINK(""" & nCell _
& """& " & cell.Address(0, 0) & ",""[A]"")"
Next cell
End Sub
___________________________________________________________________________________
_________________
Sub MakeHyperlinkFormulas()
Dim cell As Range
Dim HyperlinkAddress As String, HyperLinkText As String
For Each cell In Intersect(Selection, ActiveSheet.UsedRange)
HyperlinkAddress = Trim(cell.Text)
HyperLinkText = Trim(cell.Text)
If HyperLinkText = "" Then GoTo skipit
If HyperLinkText <> "" Then
If InStr(1, HyperlinkAddress, "@") Then
If LCase(Left(HyperlinkAddress, 7)) <> "mailto:" Then
HyperlinkAddress = "mailto:" & HyperlinkAddress
End If
Else
If InStr(1, HyperlinkAddress, ".") = 0 Then GoTo skipit
If LCase(Left(HyperlinkAddress, 7)) <> "http://" Then
HyperlinkAddress = "http://" & HyperlinkAddress
End If
End If
End If
cell.Formula = "=HYPERLINK(""" & HyperlinkAddress & _
""",""" & HyperLinkText & """)"
skipit: HyperLinkText = ""
Next cell
End Sub
___________________________________________________________________________________
_________________
Sub MakeEmailLink()
Dim cell As Range
Dim i As Long
For Each cell In Selection
If InStr(1, cell, "@") > 0 Then
With Worksheets(1)
.Hyperlinks.Add Anchor:=cell, _
Address:="mailto:" & cell.Value, _
ScreenTip:=cell.Value, _
TextToDisplay:=cell.Value
End With
End If
Next cell
End Sub
___________________________________________________________________________________
_________________

Sub BuildTOC()
'listed from active cell down 7-cols -- DMcRitchie 1999-08-14 2000-09-05
' 2000-12-24 to use =HYPERLINK
Dim iSheet As Long, iBefore As Long
Dim sSheetName As String, sActiveCell As String
Dim cRow As Long, cCol As Long, csht As Long
Dim lastcell
Dim qSht As String
Dim mg As String
Dim rg As Range
Dim CRLF As String
Dim Reply As Variant
Dim SheetCodeLines As Long
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
cRow = ActiveCell.Row
cCol = ActiveCell.Column
sSheetName = UCase(ActiveSheet.Name)
sActiveCell = UCase(ActiveCell.Value)
mg = ""
CRLF = Chr(10) 'Actually just CR
Set rg = Range(Cells(cRow, cCol), Cells(cRow - 1 + ActiveWorkbook.Sheets.Count,
cCol + 8))
rg.Select
If sSheetName <> "$$TOC" Then mg = mg & "Sheetname is not $$TOC" & CRLF
If sActiveCell <> "$$TOC" Then mg = mg & "Selected cell value is not $$TOC" &
CRLF
If mg <> "" Then
mg = "Warning BuildTOC will destructively rewrite the selected area" _
& CRLF & CRLF & mg & CRLF & "Press OK to proceed, " _
& "the affected area will be rewritten, or" & CRLF & _
"Press CANCEL to check area then reinvoke this macro (BuildTOC)"
Application.ScreenUpdating = True 'make range visible
Reply = MsgBox(mg, vbOKCancel, "Create TOC for " _
& ActiveWorkbook.Sheets.Count _
& " items in workbook" & Chr(10) & "revised will now occupy up to 10
columns")
Application.ScreenUpdating = False
If Reply <> 1 Then GoTo AbortCode
End If
rg.Clear 'Clear out any previous hyperlinks, fonts, etc in the area
For csht = 1 To ActiveWorkbook.Sheets.Count
Cells(cRow - 1 + csht, cCol) = "'" & Sheets(csht).Name
If TypeName(Sheets(csht)) = "Worksheet" Then
'hypName = "'" & Sheets(csht).Name
qSht = Replace(Sheets(csht).Name, """", """""")
If CDbl(Application.VERSION) < 8# Then
'-- use next line for XL95
Cells(cRow - 1 + csht, cCol + 2) = "'" & Sheets(csht).Name 'XL95
Else
'-- Only for XL97, XL98, XL2000 -- will create hyperlink & codename
Cells(cRow - 1 + csht, cCol + 2) = "'" & Sheets(csht).CodeName
'--- excel is not handling lots of objects well ---
'ActiveSheet.Hyperlinks.Add Anchor:=Cells(cRow - 1 + cSht, cCol), _
' Address:="", SubAddress:="'" & Sheets(cSht).Name & "'!A1"
'--- so will use the HYPERLINK formula instead ---
'--- =HYPERLINK("[VLOOKUP.XLS]'$$TOC'!A1","$$TOC")
'--- double quotes are legal in sheetnames
ActiveSheet.Cells(cRow - 1 + csht, cCol).Formula = _
"=hyperlink(""[" & ActiveWorkbook.Name _
& "]'" & qSht & "'!A1"",""" & qSht & """)"
End If
Else
Cells(cRow - 1 + csht, cCol + 2) = "'" & Sheets(csht).Name
End If
Cells(cRow - 1 + csht, cCol + 1) = TypeName(Sheets(csht))
' -- activate next line to include content of cell A1 for each sheet
' Cells(cRow - 1 + csht, cCol + 3) =
Sheets(Sheets(csht).Name).Range("A1").Value
On Error Resume Next
' sheets(cSht).type
If TypeName(Sheets(csht)) = "Module" Then GoTo byp7
Cells(cRow - 1 + csht, cCol + 6) = Sheets(csht).ScrollArea '.Address(0, 0)
Cells(cRow - 1 + csht, cCol + 7) = Sheets(csht).PageSetup.PrintArea
If TypeName(Sheets(csht)) <> "Worksheet" Then GoTo byp7
Set lastcell = Sheets(csht).Cells.SpecialCells(xlLastCell)
Cells(cRow - 1 + csht, cCol + 4) = lastcell.Address(0, 0)
Cells(cRow - 1 + csht, cCol + 5) = lastcell.Column * lastcell.Row
'--requires ref. to the MS VBA Extensibility' library
SheetCodeLines = ActiveWorkbook.VBProject.VBComponents _
(Sheets(csht).CodeName).CodeModule.CountOfLines
If SheetCodeLines > 2 Then Cells(cRow - 1 + csht, cCol + 8) = SheetCodeLines
byp7: 'xxx
On Error GoTo 0
Next csht
' GoTo AbortCode
'Now sort the results: 2. Type(D), 1. Name (A), 3. module(unsorted)
rg.Sort Key1:=rg.Cells(1, 2), Order1:=xlDescending, Key2:=rg.Cells(1, 1) _
, Order2:=xlAscending, HEADER:=xlNo, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
rg.Columns.AutoFit
rg.Select 'optional
'if cells above range are blank want these headers
' Worksheet, Type, codename
If cRow > 1 Then
If "" = Trim(Cells(cRow - 1, cCol) & Cells(cRow - 1, cCol + 1) _
& Cells(cRow - 1, cCol + 2)) Then
Cells(cRow - 1, cCol) = "Worksheet"
Cells(cRow - 1, cCol + 1) = "Type"
Cells(cRow - 1, cCol + 2) = "CodeName"
Cells(cRow - 1, cCol + 3) = "[opt.]"
Cells(cRow - 1, cCol + 4) = "Lastcell"
Cells(cRow - 1, cCol + 5) = "cells"
Cells(cRow - 1, cCol + 6) = "ScrollArea"
Cells(cRow - 1, cCol + 7) = "PrintArea"
Cells(cRow - 1, cCol + 8) = "Code"
End If
End If
Application.ScreenUpdating = True
Reply = MsgBox("Table of Contents created." & CRLF & CRLF & _
"Would you like the tabs in workbook also sorted", _
vbOKCancel, "Option to Sort " & ActiveWorkbook.Sheets.Count _
& " tabs in workbook")
Application.ScreenUpdating = False
If Reply = 1 Then SortALLSheets 'Invoke macro to Sort Sheet Tabs
Sheets(sSheetName).Activate
AbortCode:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
___________________________________________________________________________________
_________________
Sub BuildTOC_A3()
Cells(3, 1).Select
BuildTOC
End Sub
___________________________________________________________________________________
_________________
Sub SortALLSheets()
'sort sheets within a workbook in Excel 7 -- Bill Manville
'modified to sort all sheets instead of just worksheets
'called by BuildTOC macro you can use another macro...
Dim iSheet As Long, iBefore As Long
For iSheet = 1 To ActiveWorkbook.Sheets.Count
Sheets(iSheet).Visible = True
For iBefore = 1 To iSheet - 1
If UCase(Sheets(iBefore).Name) > UCase(Sheets(iSheet).Name) Then
ActiveWorkbook.Sheets(iSheet).Move Before:=ActiveWorkbook.Sheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet
End Sub
___________________________________________________________________________________
_________________
Sub Reverse_SortALLSheets()
'sort sheets within a workbook in Excel 7 -- Bill Manville
'modified to sort all sheets instead of just worksheets
'called by BuildTOC macro you can use another macro...
Dim iSheet As Long, iAfter As Long
For iSheet = 1 To ActiveWorkbook.Sheets.Count
Sheets(iSheet).Visible = True
For iAfter = 1 To iSheet - 1
If UCase(Sheets(iAfter).Name) < UCase(Sheets(iSheet).Name) Then
ActiveWorkbook.Sheets(iSheet).Move Before:=ActiveWorkbook.Sheets(iAfter)
Exit For
End If
Next iAfter
Next iSheet
End Sub
___________________________________________________________________________________
_________________

Sub EnumerateAddIns()
Dim i As Long
Worksheets("AddinsSheet").Rows(1).Font.Bold = True
Worksheets("AddinsSheet").Range("a1:d1").Value = _
Array("Name", "Full Name" & " " & Now(), "Title EnumerateAddIns()",
"Installed")
For i = 1 To AddIns.Count
Worksheets("AddinsSheet").Cells(i + 1, 1) = AddIns(i).Name
Worksheets("AddinsSheet").Cells(i + 1, 2) = AddIns(i).FullName
Worksheets("AddinsSheet").Cells(i + 1, 3) = AddIns(i).Title
Worksheets("AddinsSheet").Cells(i + 1, 4) = AddIns(i).Installed
Worksheets("AddinsSheet").Cells(i + 1, 5).Value = i
Next
Worksheets("AddinsSheet").Range("a1").CurrentRegion.Columns.AutoFit
End Sub
___________________________________________________________________________________
_________________

Sub EnumerateSheets_XL95()
'listed from active cell down 2-cols -- DMcRitchie 1999-03-04
'NOT NEEDED AS BuildTOC works for XL95, XL97, XL2000
Application.Calculation = xlManual 'xl97 up use xlCalculationManual
Application.ScreenUpdating = False
cRow = ActiveCell.Row
cCol = ActiveCell.Column
For csht = 1 To ActiveWorkbook.Sheets.Count 'worksheet or sheets
Cells(cRow - 1 + csht, cCol) = "'" & Sheets(csht).Name
Cells(cRow - 1 + csht, cCol + 1) = TypeName(Sheets(csht))
'-- include next line if you want to see cell A1 for each sheet
Cells(cRow - 1 + csht, cCol + 2) = Sheets(Sheets(csht).Name).Range("A1").Value
Next csht
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic 'xl97 up use xlCalculationAutomatic
End Sub
___________________________________________________________________________________
_________________
Sub SortSheets()
'sort worksheets within a workbook in Excel 7 -- Bill Manville
Dim iSheet As Long, iBefore As Long
MsgBox ActiveWorkbook.Worksheets.Count & "Sort Worksheets -- Bill Manville"
For iSheet = 1 To ActiveWorkbook.Worksheets.Count
Worksheets(iSheet).Visible = True
For iBefore = 1 To iSheet - 1
If UCase(Worksheets(iBefore).Name) > UCase(Worksheets(iSheet).Name) Then
ActiveWorkbook.Worksheets(iSheet).Move
Before:=ActiveWorkbook.Worksheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub ReOrderSheets()
' page 48 in "Using Excel VBA" Jeff Webb
'for each sheet in a workbook ...
Dim shtcount As Name, iWrk As Long, iChrt As Long
Dim iMod As Long, iDlg As Long

MsgBox "ReorderSheets -- sorting worksheets -- jeff webb"


For Each shtcount In Sheets
'group the different types of sheets together
Select Case TypeName(shtcount)
Case "Worksheet"
iWrk = iWrk + 1
shtcount.Move After:=Sheets(iWrk)
Case "Chart"
iChrt = iChrt + 1
shtcount.Move After:=Sheets(Worksheets.Count + iChrt)
Case "Module"
iMod = iMod + 1
shtcount.Move After:=Sheets(Worksheets.Count + Charts.Count + iMod)
Case "DialogSheet"
iDlg = iDlg + 1
shtcount.Move After:=Sheets(Worksheets.Count + Charts.Count +
Modules.Count + iDlg)
End Select
Next shtcount
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub ShowSheets()
'Unhide sheets -- Tom Ogilvy 17Jun1999
'Should show all sheets as long as the workbook level protection
' is notturned on.
Dim sh As Variant
For Each sh In Sheets
sh.Visible = True
Next
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub Build_SS_Button()
'Build button on spreadshee to invoke macro
'adapted from a posting by "Jim/Nospam" on 30Aug1999
ActiveCell.Select
Selection.Copy
ActiveSheet.Pictures.Add(251, 88, 75, 13).Select
Selection.Interior.ColorIndex = 8
Application.CutCopyMode = False
Selection.OnAction = ActiveCell.Value 'Macro to be invoked
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Private Function HyperlinkAddress(cell) As String


If cell.Hyperlinks.Count > 0 Then _
HyperlinkAddress = cell.Hyperlinks(1).Address
End Function

Private Function indented(cell) As Long


'Leading/Left Spaces count, D.McRitchie 2007-07-26
LSpaces = cell.IndentLevel 'cell padding on left
End Function

Private Function LSpaces(cell) As Long


'Leading/Left Spaces count, D.McRitchie 2007-07-26
LSpaces = Len(Text) - Len(LTrim(Replace(Text, Chr(160), " ", , , vbTextCompare)))
End Function

Private Function ExtractFilename(cell) As String


'D.McR 2006-07-31 extract filename w/o ext from full pathname
Dim str As String, newstring As String
str = cell
If InStr(str, "\") = 0 Then
ExtractFilename = str
Exit Function
End If
newstring = Mid(str, InStrRev(str, "\", , vbTextCompare) + 1)
If InStr(newstring, ".") = 0 Then
ExtractFilename = newstring
Exit Function
End If
str = Left(str, InStr(newstring, ".") - 1)
ExtractFilename = str
End Function
Private Function HyperlinkFilename(cell) As String
'D.McR 2006-07-31 extract filename w/o ext from an object link
Dim str As String, newstring As String
str = cell.Hyperlinks(1).Address
If cell.Hyperlinks.Count < 1 Then Exit Function
If InStr(str, "\") = 0 Then
HyperlinkFilename = str
Exit Function
End If
newstring = Mid(str, InStrRev(str, "\", , vbTextCompare) + 1)
If InStr(newstring, ".") = 0 Then
HyperlinkFilename = newstring
Exit Function
End If
str = Left(str, InStr(newstring, ".") - 1)
HyperlinkFilename = str
End Function
Function HyperLinkText(oRange As Range) As String
'-- Bill Manville, 2002-97-26, excel.links
'-- includes Excel internal links
Dim ST1 As String, ST2 As String
If oRange.Hyperlinks.Count = 0 Then Exit Function
ST1 = oRange.Hyperlinks(1).Address
ST2 = oRange.Hyperlinks(1).SubAddress
If ST2 <> "" Then ST1 = "[" & ST1 & "]" & ST2
HyperLinkText = ST1
End Function

Function HyperlinkScreenTip(cell)
On Error Resume Next
HyperlinkScreenTip = cell.Hyperlinks(1).ScreenTip
If HyperlinkScreenTip = 0 Then HyperlinkScreenTip = ""
End Function
Function url(cell As Range)
'Tom Ogilvy, programming 1999-04-14 Deja: AN=468281862
'Chip Pearson, programming 1999-04-14 Deja: AN=468345917
'David McRitchie, combined 1999-11-13
'cannot process imbedded link to internal sheet yet ...
If Trim(cell.Formula) = "" Then
url = ""
Exit Function
End If ' 1234567890122
If Left(UCase(cell.Formula), 11) = "=HYPERLINK(" Then
If Left(UCase(cell.Formula), 12) = "=HYPERLINK(""" Then
url = Mid(cell.Formula, 13, InStr(1, cell.Formula, ",") - 13)
Exit Function 'next part for nonquoted first parm
End If
url = Mid(cell.Formula, 12, InStr(1, cell.Formula, ",") - 12)
Exit Function
End If
url = ""
On Error Resume Next
url = cell.Hyperlinks(1).Address
If url = 0 Then url = "'**"
End Function
Function URLHREF(cell As Range)
'As an aid to sorting a list of hyperlinked articles 2004-06-22 xlindex.htm
'="<DD><a href=""" & SUBSTITUTE(pesonal.xls!url(A1),"..\..\..\temp\","") & """>" &
A1 & "</a>"
Dim txt As String
If cell.Font.Bold Then
txt = "<b>" & cell.Text & "</b>"
Else
txt = cell.Text
End If
If url(cell) = "" Then
URLHREF = txt
Else
URLHREF = "<DD><a href=""" & Replace("..\..\..\temp\", "", url(cell)) _
& """>" & txt & "</a>"
End If
End Function
Sub URLCHANGE()
' must reduce the presented string to the
' leading portion that you want to change
' David McRitchie, 2000-11-13, may not work properly
'also see Fix192url macro in builttoc.htm
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim cell As Range, savevalue As String
Dim fromstr As String, tostr As String, fromtst As String
Dim updated As Long
fromstr = "d:\newsite\davemcritchie\excel\"
tostr = "http://www.mvps.org/dmcritchie/excel/"
fromtst = fromstr
updated = 0
Dim urlstr As String, i As Long
fromstr = InputBox("supply from url portion", "URLCHANGE", _
Selection.Hyperlinks(1).Address)
If fromstr = "" Then Exit Sub
If UCase(fromstr) <> UCase(fromtst) Then
tostr = fromstr
tostr = InputBox("supply to url portion, to replace" _
& " " _
& Chr(10) & fromstr, "URLCHANG part 2", tostr)
If tostr = "" Then Exit Sub
End If
For Each cell In Selection
On Error Resume Next
savevalue = cell.Value
Err.number = 0
urlstr = cell.Hyperlinks(1).Address
If Err.number = 0 Then
On Error GoTo 0 'rest back to normal default
If Left(UCase(urlstr), Len(fromstr)) = UCase(fromstr) Then
urlstr = tostr & Mid(urlstr, Len(fromstr) + 1, 9999)
cell.Hyperlinks(1).Address = urlstr
cell.Hyperlinks(1).TextToDisplay = urlstr
cell.Value = savevalue
updated = updated + 1
End If
End If
On Error GoTo 0 'rest back to normal default
Next cell
MsgBox "processed " & updated & " cells"
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub MakeTextOnlyFromHyperlinks()
'David McRitchie, 2000-08-23 worksheet.functions !!
Dim cell As Range
Dim url As String
For Each cell In Selection
If IsEmpty(cell) Then GoTo chknext
url = ""
On Error Resume Next
url = cell.Hyperlinks(1).Address
'MsgBox cell.Address & " -- " & Err.Number & " -- " & URL
If Err.number = 9 Then GoTo chknext
If Trim(url) = "" Then GoTo chknext
cell.Value = url
cell.Hyperlinks(1).Delete
chknext: On Error GoTo 0
Next cell
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub OneSheet_TOC()
'basis Chip Pearson, misc 2000-10-08 CreateIndex
' -- mod. to summarize fromName-ToName, page
'Scans through column A on Sheet1,
'and creates a page index of each "group" of values onto Sheet2.
'Earlier code basis may be Laurent Longre 2000-03-05 programming
' which placed page ?? of ??? right on the spreadsheet.
' http://www.deja.com/=dnc/getdoc.xp?AN=593502826
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim rng As Range
Dim Dest As Range
Dim HPB As HPageBreak
Dim pagenumber As Long
Dim PageRows() As Long
Dim xx As String: xx = ""
Dim bastard1004 As Boolean
ReDim PageRows(0 To Worksheets("Sheet1").HPageBreaks.Count, 0 To 1)
pagenumber = 1
Set rng = Worksheets("Sheet1").Range("A1")
Set Dest = Worksheets("Sheet2").Range("A1")
' From, To, Page, Row
Dest(1, 1) = rng(1, 1)
Dest(1, 2) = rng(1, 1)
Dest(1, 3) = pagenumber
Dest(1, 4) = rng.Row
For Each HPB In Worksheets("Sheet1").HPageBreaks
xx = xx & ", " & HPB.Location.Row
Dest(pagenumber, 2) = rng(HPB.Location.Row - 1, 1)
pagenumber = pagenumber + 1
Dest(pagenumber, 1).Value = rng(HPB.Location.Row, 1)
Dest(pagenumber, 2).Value = rng(HPB.Location.Row, 1)
Dest(pagenumber, 3).Value = pagenumber
Dest(pagenumber, 4).Value = HPB.Location.Row
Next HPB
Worksheets("sheet1").UsedRange
Dest(pagenumber, 2).Value = _
rng.Cells(rng.Cells.SpecialCells(xlLastCell).Row, 1).Value
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox Mid(xx, 2, 9999) & ", " & Chr(187) & _
rng.Cells.SpecialCells(xlLastCell).Row & _
Chr(10) & Chr(187) & " Based on LastCell"
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub GetAllA1Cells()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Dim iSheet As Long
For iSheet = 1 To ActiveWorkbook.Worksheets.Count
ActiveCell.Offset(iSheet - 1, 0) = Worksheets(iSheet).[A1].Value
ActiveCell.Offset(iSheet - 1, 1) = "'" & Worksheets(iSheet).Name
Next iSheet
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
Sub ResetScrollArea()
ActiveSheet.ScrollArea = InputBox("Supply Scroll area " & _
"or blank out to remove", _
"Supply Scroll Area", ActiveSheet.ScrollArea)
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub GoToSub(Optional thissub As String)


'Display Subroutine or Function named in selected cell
'David McRitchie 1999-11-12 rev. 2000-04-13
'http://www.mvps.org/dmcritchie/excel/buildtoc.htm
Dim i As Long, trysub As String
trysub = thissub
On Error GoTo notfound2
If thissub <> "" Then
Application.DisplayAlerts = False
Application.Goto Reference:=trysub
On Error GoTo notfound
Application.DisplayAlerts = True
End If
On Error GoTo notfound 'formerly named GoToSubroutine
trysub = Trim(ActiveCell.Value)
Application.Goto Reference:=trysub
Exit Sub
notfound:
On Error GoTo notfound2
If Left(ActiveCell.Formula, 1) = "=" Then
For i = 1 To Len(ActiveCell.Formula)
If Mid(ActiveCell.Formula, i, 1) = "(" Then
Application.Goto Reference:=Mid(ActiveCell.Formula, 2, i - 2)
Exit Sub
End If
Next i
MsgBox Mid(ActiveCell.Formula, 2, i - 2) _
& "was not found as a User Defined Function, " _
& "verify with Paste Function Wizard [fx]"
End If
notfound2:
If InStr(1, ActiveCell.Formula, "!") Then GoTo notfound3
On Error GoTo notfound3
Application.Goto Reference:="pesonal.xls!" & Trim(ActiveCell.Value)
MsgBox "Adding the prefix that you didn't specify, pesonal.xls!"
Exit Sub
notfound3:
On Error GoTo 0
MsgBox "Procedure or Function " & ActiveCell.Value _
& " is not available, try ALT+F8 to find Sub, or [fx] to find UDF"
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub time_RunSubFromActiveCell()
'David McRitchie see slowresp.htm & buildtoc.htm for more information
Dim myTime(4) As Double
myTime(1) = timeGetTime()
'... Your code here for timing
Call RunSubFromActiveCell
'... End of Your code here for timing
myTime(2) = timeGetTime()
MsgBox Format((myTime(2) - myTime(1)) / 1000, "#.000") _
& " seconds, "
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

Sub A1TopLeft()
'Application.Goto Reference:=Range(ActiveCell.Address), Scroll:=True
Application.Goto Reference:=Range("A1"), Scroll:=True
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
Sub RunSubFromActiveCell()
'-- examples of what you type into a cell for this to work on
' ''macro1'
' ''personal.xls'!upper_case
Dim myTime(4) As Double 'updated 2005-04-29 to include timing
Dim actcell As String, bigmess As String, i As Long
actcell = Trim(ActiveCell.Text)
If InStr(ActiveCell.Text, ".xls'!") And _
Left(ActiveCell.Text, 1) <> "'" Then
MsgBox "you need two single quotes at beginning of " & ActiveCell.Text
End If
i = InStr(ActiveCell.Text, ".xls!")
If i > 0 Then 'mod. 2006-05-24 now compatible with GoToSub and macro menu
'-- must be in form 'book.xls'!macroname to actually run
actcell = "'" & Left(actcell, i + 3) & "'" & Mid(actcell, i + 4, 255)
End If
bigmess = actcell
myTime(1) = timeGetTime()
On Error Resume Next
Err.Clear
If Left(actcell, 1) <> "'" Then
Application.Run "'" & Trim(actcell) & "'"
Else
'-- first single quote does not count it means text field
'-- i.e. ''pesonal.xls'!Test_SP_create_crap
Application.Run actcell
End If
On Error GoTo 0
If Err.number <> 0 Then
actcell = "'" & ActiveWorkbook.Name & "'!" & actcell
myTime(1) = timeGetTime()
Err.Clear
Application.Run actcell
If Err.msg <> 0 Then
bigmess = Err.number & " for " & actcell _
& Chr(13) & Err.Description
Err.Clear
End If
End If
myTime(2) = timeGetTime()
On Error GoTo 0
MsgBox Format((myTime(2) - myTime(1)) / 1000, "#.000") _
& " seconds for " & bigmess
'- examples of tests upper_case ="'2004-11.XLS'!DUMBO_CASE"
'- ''2004-11.xls'!yougotit
'- because this macro runs from personal.xls you must supply bookname.

End Sub
___________________________________________________________________________________
_________________

Sub RunSubFromActiveTest()
'place RunSubFromActiveTest in a cell and run RunSubFromActiveCell
MsgBox "have successfully tested RunSubFromActiveCell"
End Sub
___________________________________________________________________________________
_________________
Sub LinkFix()
' Dana DeLouis 2001-03-19 misc, using an
' Idea From: Chip Pearson
' http://www.cpearson.com/excel/clipboar.htm
'= = = = = = = = =
' VBA Lib.Ref.: Microsoft Forms 2.0 object lib.
' Excel 2000 due to Replace() Function.
'= = = = = = = = =
Dim MyDataObj As New DataObject
MyDataObj.GetFromClipboard
Dim nLnk As String
slnk = Replace(MyDataObj.GetText, _
vbCr, vbNullString)
slnk = Replace(slnk, vbLf, vbNullString)
slnk = Replace(slnk, vbLf, vbNullString)
slnk = Replace(slnk, ">", vbNullString)
slnk = Replace(slnk, " ", vbNullString)
slnk = Replace(slnk, Chr(160), vbNullString)
MyDataObj.SetText slnk
MyDataObj.PutInClipboard
Set MyDataObj = Nothing
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
'MakeHTML_Link has been moved to it's own code module

Function MSKBQ(qstr As String) As String


Dim L As Long
MSKBQ = qstr
If LCase(Left(qstr, 1)) <> "q" Then GoTo done
L = Len(qstr)
If Not IsNumeric(Right(qstr, L - 1)) Then GoTo done
If L < 7 Or L > 10 Then GoTo done
' MSKBQ = "http://support.microsoft.com/support/kb/articles/" & _
Left(qstr, l - 3) & "/" & Mid(qstr, l - 2, 1) _
& "/" & Right(qstr, 2) & ".asp"
MSKBQ = "http://support.microsoft.com/?id=kb;en-us;" & UCase(qstr)
done:
End Function

Sub LinkFix_GoTo()
' Dana DeLouis 2001-03-19 misc,
' Dave Peterson, added FollowHyperlink
' Idea From: Chip Pearson
' www.cpearson.com/excel/clipboar.htm
'= = = = = = = = =
' VBA Library Reference:
' Microsoft Forms 2.0 object lib.
' Excel 2000 due to Replace() Function.
'= = = = = = = = =
Dim MyDataObj As New DataObject
Dim lnk As String
On Error Resume Next
MyDataObj.GetFromClipboard
lnk = Replace(MyDataObj.GetText, _
vbCrLf, vbNullString)
Set MyDataObj = Nothing
ActiveWorkbook.FollowHyperlink _
Address:=lnk, NewWindow:=True
End Sub
___________________________________________________________________________________
_________________
'Sub IdentifyNonFormulaLinks()
' Cells.Hyperlinks.Count
' If Cells.Hyperlink.Count = 0 Then Exit Sub
' cells.hyperlinks.select '<-- not legal
'End Sub
___________________________________________________________________________________
_________________

'querylastcells moved to mcritchie_lastcell module

Sub CB_List()
Worksheets.Add
'Cells(i, 3) = c.enable
Dim i As Long
i = 1
Cells(i, 1) = "Name"
Cells(i, 2) = "Enabled"
Cells(i, 3) = "BuiltIn"
Cells(i, 4) = "Index"
Cells(i, 5) = "Visible"
Cells(i, 6) = "Context"
Cells(i, 7) = "Controls"
Cells(i, 8) = "Creator"
Cells(i, 9) = "Parent"
Cells(i, 10) = "Application"
Dim c As CommandBar
For Each c In CommandBars
On Error GoTo 0
i = i + 1
Cells(i, 1) = c.Name
If c.Enabled = True Then Cells(i, 3) = "True"
On Error Resume Next
Cells(i, 3) = c.BuiltIn
Cells(i, 4) = c.Index
Cells(i, 5) = c.Visible
Cells(i, 6) = c.Context
Cells(i, 7) = c.Controls
Cells(i, 8) = c.Creator
Cells(i, 9) = c.Parent
Cells(i, 10) = c.Application

Next c
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
Sub RevertToLink()
Dim cell As Range
For Each cell In Selection
' On Error Resume Next
cell.Value = cell.Hyperlinks(1).Address
'If cell = 0 Then cell = ""
Next cell
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
Sub volatileS()
Dim rng As Range, cell As Range, c As Range
' CELL(), INDIRECT(), INFO(), OFFSET(), NOW(), RAND(), TODAY()
' Set c = Union(Cells.Find("CELL(", , xlFormulas), _
' Cells.Find("INDIRECT(", , xlFormulas), _
' Cells.Find("INFO(", , xlFormulas), _
' Cells.Find("OFFSET(", , xlFormulas), _
' Cells.Find("NOW(", , xlFormulas), _
' Cells.Find("RAND(", , xlFormulas), _
' Cells.Find("TODAY(", , xlFormulas))
' If Not c Is Nothing Then MsgBox "Volatile"
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________

H="Sub ReplaceHyperlinkAddress(FromAddress As String, ToAddress As String)"

Sub ReplaceHyperlinkAddress(FromAddress As String, ToAddress As String)


' Bill Manville, Links, 2003-01-01
'-- - Sub FixMyLinks()
'-- - Call ReplaceHyperlinkAddress("cbsonline.com", "cbs.com")
'-- - End Sub
___________________________________________________________________________________
_________________
Dim H As Hyperlink
Dim WS As Worksheet
MsgBox FromAddress & " == " & ToAddress
For Each WS In ActiveWorkbook.Worksheets
For Each H In WS.Hyperlinks
If InStr(1, H.Address, FromAddress, vbTextCompare) > 0 Then
H.Address = Replace(H.Address, FromAddress, ToAddress, _
vbTextCompare)
End If
Next
Next
End Sub
___________________________________________________________________________________
_________________

Function getdomain(url As String) As String


Dim x As String, i As Long, j As Long
x = url
i = InStr(x, "://")
If i <> 0 Then x = Mid(x, i + 3)
i = InStr(x, ".")
If i = 0 Then
getdomain = x
Exit Function
End If
i = InStr(x, "/")
If i <> 0 Then x = Left(x, i - 1)
x = strReverse(x)
i = InStr(x, ".")
j = InStr(Mid(x, i + 1), ".")
getdomain = x & " " & i & " " & j
If j = 0 Then
getdomain = strReverse(x)
Else
getdomain = strReverse(Left(x, i + j - 1))
End If
End Function

Function MSGID_asLink(msg)
' David McRitchie 2004-=6-24 as Function
Dim slnk As String
slnk = msg
slnk = Replace(slnk, vbCr, vbNullString)
slnk = Replace(slnk, vbLf, vbNullString)
slnk = Replace(slnk, ">", vbNullString)
slnk = Replace(slnk, "<", vbNullString)
slnk = Replace(slnk, " ", vbNullString)
slnk = Replace(slnk, Chr(160), vbNullString)
slnk = Replace(slnk, "Message-ID:", "news:")
slnk = Replace(slnk, "References:", "news:")
slnk = Replace(Replace(slnk, "#", "%23"), "$", "%24")
MSGID_asLink = slnk
End Function
Function HTMLify(cell As String) As String
' David McRitchie 2005-06-06
Dim slnk As String
slnk = cell
slnk = Replace(slnk, "&", "&amp;")
slnk = Replace(slnk, "<", "&lt;")
slnk = Replace(slnk, ">", "&gt;")
slnk = Replace(slnk, "<", "&lt;")
HTMLify = slnk
End Function
Sub Make_oldhyp()
Dim cell As Range, i As Long, vvv As Variant, lnk As String
Dim L As Long
For Each cell In Intersect(Selection, Cells.SpecialCells(xlCellTypeFormulas))
If UCase(Left(cell.Formula, 12)) = "=HYPERLINK(""" Then
i = InStr(1, cell.Formula, """,")
L = Len(cell.Formula)
lnk = Mid(cell.Formula, 13, i - 13)
With Worksheets(1)
.Hyperlinks.Add Anchor:=cell, Address:=lnk
'cell.Formula = "=" & Mid(cell.Formula, i + 2, L - i - 2)
cell.Value = cell.Value
End With
End If
Next cell
End Sub
___________________________________________________________________________________
_________________

H="Option explicit 2, (_+_)gotostuff(_<^>_)"


'Option Explicit
'Not all have been tested for use with Option Explicit
'Documented in http://www.mvps.org/dmcritchie/excel/buildtoc.htm
'Documented in http://www.mvps.org/dmcritchie/excel/toolbars.htm
'Coding: http://www.mvps.org/dmcritchie/excel/code/buildtoc.txt
'Coding: http://www.mvps.org/dmcritchie/excel/code/gotostuff.txt
'My Excel Macros: http://www.mvps.org/dmcritchie/excel/excel.htm
' David McRitchie
'------------------------------------------------
'- 2 subroutines use these by Brian Wilson, Excel Misc, 2000-08-03
Public ThisCell As String
Public ThisSheet As String
Sub GoToCellInFormula()
'Brian Wilson, Excel Misc, 2000-08-03
' go to the first cell referenced in the activecell FORMULA
'
ThisSheet = ActiveSheet.Name
ThisCell = ActiveCell.Address
Selection.ShowPrecedents
ActiveCell.NavigateArrow TowardPrecedent:=True, _
ArrowNumber:=1, LinkNumber:=1
Worksheets(ThisSheet).ClearArrows
End Sub
___________________________________________________________________________________
_________________

Sub TakeMeBack()
'Brian Wilson, Excel Misc, 2000-08-03
' return to the original cell
'
Worksheets(ThisSheet).Activate
Range(ThisCell).Activate
End Sub
___________________________________________________________________________________
_________________

Sub GoToCell_old()
'David McRitchie 2000-08-03, cont'd based on Brian Wilson
Dim i As Long
ThisSheet = ActiveSheet.Name
ThisCell = ActiveCell.Address
Dim vCell As String
vCell = ActiveCell.Value
i = InStr(1, vCell, "!", 0)
If i <> 0 Then
Sheets(Left(vCell, i - 1)).Activate
Range(Trim(Mid(vCell, i + 1, 99))).Activate
Exit Sub
Else
On Error GoTo TrySheet
Range(vCell).Select
Exit Sub
End If
TrySheet:
On Error GoTo NF
Sheets(ActiveCell.Value).Select
Exit Sub
NF:
MsgBox "Invalid cell, sheetname, or sheetname!cell"
End Sub
___________________________________________________________________________________
_________________
'---------------------------------

Sub GoToCell()
'David McRitchie 2000-08-03, simplified 2001-03-04 by Dana DeLouis
On Error GoTo NF
Application.Goto Range(ActiveCell.Value)
Exit Sub
NF:
MsgBox "GoToCell failed at " & ActiveCell.Address & Chr(10) & _
" with invalid sheetname and/or cell address, attempting " & _
Chr(10) & " to process: " & ActiveCell.Value
End Sub
___________________________________________________________________________________
_________________

Sub GotoTopOfCurrentColumn()
'Graham Tooley" <GrahamTooley@Xtra.co.nz> 23Apr1998
'ActiveCell.EntireColumn.Cells(1, 1).Select
Cells(1, ActiveCell.Column).Select 'J.Campion 2000-03-20
'would like to hit ctrl or shift + and use this, Tom Ogilvy 2000-06-26
'Cells(Rows.Count, ActiveCell.Column).End(xlUp).Select
End Sub
___________________________________________________________________________________
_________________
Sub GotoBottomOfCurrentColumn()
'Tom Ogilvy 2000-06-26
Cells(Rows.Count, ActiveCell.Column).End(xlUp).Select
End Sub
___________________________________________________________________________________
_________________

Sub GotoBottomOfColumnA_PlusOne()
'Tom Ogilvy 2000-06-26
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
'Tom Ogilvy 2001-04-11
' Dim rng As Range
' Set rng = Cells(Rows.Count, "A").End(xlUp)(2)
' rng.Select
End Sub
___________________________________________________________________________________
_________________
Sub SelectToBottom()
Range(ActiveCell.Address, _
Cells(Rows.Count, ActiveCell.Column).End(xlUp).Address).Select
'-- copy selection to to clipboard
Selection.Copy
End Sub
___________________________________________________________________________________
_________________
Sub GotoRightOfCurrentRow() 'D.McRitchie 2003-12-08 based on Tom Ogilvy
Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1).Select
End Sub
___________________________________________________________________________________
_________________
Sub GotoRightmostOfCurrentRow()
If Not (IsEmpty(Cells(ActiveCell.Row, Columns.Count))) Then
Cells(ActiveCell.Row, Columns.Count).Select
Exit Sub
End If
Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Select
'wsFunct: {=ADDRESS(1,MAX(IF(1:1<>"",COLUMN(1:256),"")),4)} t.ogilvy 2000-09-25
End Sub
___________________________________________________________________________________
_________________

'wsFunct to get value of rightmost cell on a row -- Don Guillet 2003-12-09, misc
'One way. Must be array entered (Ctrl+Shift+Enter). copy down
'=OFFSET(A3,0,-1+MAX(ISNUMBER(3:3)*COLUMN(1:256)))

Sub gotolastnotlen0()
Dim lstrow As Long, i As Long 'D.McRitchie 2000-12-04 prog.
lstrow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
For i = lstrow To 1 Step -1
If Len(Cells(i, ActiveCell.Column)) <> 0 Then GoTo done
Next i
done:
Cells(i, ActiveCell.Column).Select
End Sub
___________________________________________________________________________________
_________________

Sub GotoHomeOfCurrentRow()
Cells(ActiveCell.Row, 1).Select
'Same as Home key -- as long a no Transition keys
End Sub
___________________________________________________________________________________
_________________

Sub MoveDown() 'D.McRitchie 2000-10-16 like ArrowDn


ActiveCell.Offset(1, 0).Activate
End Sub
___________________________________________________________________________________
_________________
Sub MoveUp() 'D.McRitchie 2000-10-16 like ArrowUp
ActiveCell.Offset(-1, 0).Activate
End Sub
___________________________________________________________________________________
_________________
'---------------------------------
Sub GoTo_XLFDIC()
'David McRitchie 2001-01-14 Bring up Peter Noneley's Excel Function Dictionary
'David McRitchie xxxx www.mvps.org/dmcritchie/excel/buildtoc.htm
Dim wantedsheet As String
If ActiveCell.Value = "" Then Exit Sub
'wantedsheet = "'[C:\Documents and Settings\Administrator\Desktop\XLFDIC01.XLS]"
_
' & Trim(ActiveCell.Value) & "'!A1"

Workbooks.Open(filename:= _
"C:\Documents and
Settings\Administrator\Desktop\XLFDIC01.XLS").RunAutoMacros _
Which:=xlAutoOpen
'Range("[C:\Documents and Settings\Administrator\Desktop\XLFDIC01.XLS]'"
' & Trim(ActiveCell.Value) & "'a1").Select
'Application.Goto Reference:="'" & Trim(ActiveCell.Value) & "'!a1"

On Error Resume Next


If Sheets(ActiveCell.Text) Is Nothing Then
MsgBox "Worksheet " & wantedsheet & " was not found, use RClick on " _
& "Sheet Tab Navigation arrow in lower left corner " _
& "to find desired sheetname."
Else
Sheets(ActiveCell.Text).Select
End If
On Error GoTo 0
End Sub
___________________________________________________________________________________
_________________

Sub GoToCellF()
'David McRitchie testing 2002-10-11
'usage A3: =Data!B14
' macro will take you to Cell at 'data'!B14
'simulates double click of such a formula when options
' tools, options, edit (tab), [uncheck] Edit directly in cell
On Error GoTo NF
Application.Goto Reference:=Application.Range(Mid(ActiveCell.Formula, 2))
Exit Sub
NF:
MsgBox "GoToCell failed at " & ActiveCell.Address & Chr(10) & _
" with invalid sheetname and/or cell address, attempting " & _
Chr(10) & " to process single cell reference in formula: " _
& ActiveCell.Formula
End Sub
___________________________________________________________________________________
_________________
Sub GoToSheet()
'David McRitchie www.mvps.org/dmcritchie/excel/buildtoc.htm
Dim wantedsheet As String
wantedsheet = Trim(ActiveCell.Text)
If wantedsheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Text) Is Nothing Then
MsgBox "Worksheet " & wantedsheet & " was not found, use RClick on " _
& "Sheet Tab Navigation arrow in lower left corner " _
& "to find desired sheetname."
Else
Sheets(ActiveCell.Text).Select
End If
On Error GoTo 0
End Sub
___________________________________________________________________________________
_________________

Sub GoToTOC()
On Error Resume Next
Sheets("$$TOC").Select
If Err.number <> 0 Then MsgBox "$$TOC Sheet Not Found"
End Sub
___________________________________________________________________________________
_________________
Sub GoToSheetofNextCell()
On Error Resume Next
Sheets(ActiveCell.Offset(0, 1).Value).Select
If Err.number <> 0 Then MsgBox ActiveCell.Offset(0, 1).Value & _
" sheet not found relating to " & ActiveCell.Value
End Sub
___________________________________________________________________________________
_________________
Sub GoToEnteredSheetName()
On Error Resume Next
Err.number = 0
Dim EmpNo As String
EmpNo = InputBox("Enter Sheet name", "Sheet Name Entry", _
ActiveCell.Value, , vbOKCancel)
If EmpNo = "" Then Exit Sub 'empty or hit Cancel
Sheets(EmpNo).Select
If Err.number <> 0 Then MsgBox EmpNo & _
" sheet not found"
End Sub
___________________________________________________________________________________
_________________
Sub GoToNextSheet()
'David McRitchie, 2000-09-07 not posted
'Toolbar button [+]
On Error Resume Next
ActiveSheet.Next.Select
If Err.number = 91 Then
MsgBox Err.number & " You are already in the last worksheet"
End If
End Sub
___________________________________________________________________________________
_________________
Sub GoToPrevSheet()
'David McRitchie, 2000-09-07 not posted
'Toolbar button [-]
On Error Resume Next
'Dim strng As String
'strng = ActiveCell.Address(0, 0)
ActiveSheet.Previous.Select
If Err.number = 91 Then
MsgBox "This is the first worksheet, there are " & _
"no worksheet tabs to left"
End If
'ActiveSheet.Range(strng).Select
End Sub
___________________________________________________________________________________
_________________
Sub GoToLastSheet()
'David McRitchie, 2002-02-27
On Error Resume Next
Sheets(Sheets.Count).Select
End Sub
___________________________________________________________________________________
_________________
Sub GoToSpecificSheet()
'David McRitchie, 2000-11-15 misc
On Error Resume Next
Dim getsheet As String
retry9:
getsheet = InputBox("Supply name of sheet to be selected", _
"Select a Sheet", ActiveSheet.Name)
If getsheet = "" Then Exit Sub 'cancelled
Sheets(getsheet).Select
If Err.number <> 0 Then
MsgBox "sheet """ & getsheet & """ not found, respecify or cancel"
Err.number = 0
GoTo retry9
End If
End Sub
___________________________________________________________________________________
_________________

Sub GoToCustomerSheet()
'David McRitchie 2000-07-15 excel.programming
Dim wantedsheet As String
wantedsheet = Trim(ActiveCell.Value)
wantedsheet = InputBox("Please Supply Customer Name" _
& Chr(10) & "This should match a sheetname", _
"Specify Customer")
If wantedsheet = "" Then Exit Sub
On Error Resume Next
'to goto a cell you still need to slect the sheet first
Sheets(wantedsheet).Select
Sheets(wantedsheet).Range("B14").Select 'Optional
If Err = 9 Then 'actually is subscript out of range
MsgBox "Your worksheet was not found use RClick on " _
& "Sheet Tab Navigation arrow in lower left corner " _
& "to find desired sheetname."
End If
End Sub
___________________________________________________________________________________
_________________

Sub GoToHyperlink()
'selected cell contains Sheet1!Z100
' goto indicated sheet and cell, scroll to display cell in top left corner
Application.Goto Reference:=Range(ActiveCell.Value), Scroll:=True
End Sub
___________________________________________________________________________________
_________________

H="Sub GoToHTML()"Sub GoToHTML()

Sub GoToHTML()
'David McRitchie, 2000-12-13
'documented in http://www.mvps.org/dmcritchie/excel/buildtoc.htm
On Error Resume Next
If Len(Trim(ActiveCell.Value)) = 0 Then Exit Sub
ActiveWorkbook.FollowHyperlink Address:=ActiveCell.Value, _
NewWindow:=False, AddHistory:=True
If Err.number <> 0 Then
MsgBox Err.number & " " & Err.Description & Chr(10) & _
"Tried to bring up file in " & ActiveCell.Address(0, 0) & _
Chr(10) & "Source: " & Err.Source & Chr(10) & _
Chr(10) & "Content: " & Chr(10) & ActiveCell.Text
End If
'Application.WindowState = xlNormal -- what would this do?
End Sub
___________________________________________________________________________________
_________________

H="Sub backupBYDATE()"

Sub backupBYDATE()
'Don Guillett, misc, 2000-05-08 modified filename for date......
'documented in http://www.mvps.org/dmcritchie/excel/backup.htm
Dim dname As String, strTest As String
dname = "c:\mybackup\B" & Format(Now(), "yyyy_mmdd")
strTest = Dir(dname, vbDirectory)
If (strTest = "") Then MkDir (dname)
ActiveWorkbook.SaveCopyAs dname & "\BK_" & ActiveWorkbook.Name
ActiveWorkbook.Save 'also save current file
End Sub
___________________________________________________________________________________
_________________

'Active cell repositioned to Top also showing 5 cells to left


' remains on same sheet
Sub ShowTopLeft5()
Dim caddr As String
caddr = Selection.Address
Application.Goto Reference:=Cells(ActiveCell.Row, _
Application.WorksheetFunction _
.Max(1, ActiveCell.Column - 5)), Scroll:=True
Range(caddr).Select
End Sub
___________________________________________________________________________________
_________________

'repositition active cell to Top Left corner


' remains on same sheet
Sub ShowTopLeft()
Application.Goto Reference:=Range(ActiveCell.Address), Scroll:=True
End Sub
___________________________________________________________________________________
_________________
Sub Goback1()
MsgBox Application.PreviousSelections(1).Address
End Sub
___________________________________________________________________________________
_________________
Sub GoBack(Optional n As Byte = 1)
'////////////////not working//////////////////
MsgBox Application.PreviousSelections(1).Address
On Error GoTo noSelections
For i = LBound(Application.PreviousSelections) To _
UBound(Application.PreviousSelections)
MsgBox Application.PreviousSelections(i).Address
Next i
Exit Sub
On Error GoTo 0

noSelections:
MsgBox "xxxx"
'// Bug fixed in Excel 2000. (multi-Areas)
'posted 2001-02-28 Dana DeLouis programming
'-- Excel can go back up to the last 4 active sheets.
MsgBox n & " --- " & Application.PreviousSelections(1).Address

If n > 4 Then
MsgBox "Max n for GoBack is 4 !"
Stop: Exit Sub
End If

With Application.PreviousSelections(n)
Workbooks(.Parent.Parent.Name).Activate
Worksheets(.Parent.Name).Activate
Range(.Address).Select
End With
End Sub
___________________________________________________________________________________
_________________

Sub testchad()

Selection.Item(Selection.Count).Activate
' Range("A1:F200").Item(Range("A1:F200").Count).Activate
End Sub
___________________________________________________________________________________
_________________

'Private Sub Workbook_BeforeClose(cancel As Boolean)


' -- noticeable slow down and forced/save verification
' Application.Run "personal.xls!Select_A1_AllSheets"
'End Sub
___________________________________________________________________________________
_________________

Sub Select_A1_AllSheets()
Dim wks As String
Dim sht As Worksheet
Application.ScreenUpdating = False
wks = ActiveSheet.Name
On Error GoTo done
For Each sht In Worksheets
Application.Goto Reference:=sht.Range("A1"), Scroll:=True
Next sht
Sheets(wks).Select
done:
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________

Sub Select_A1_AllSheets_only()
'if scroll to A1 is not important then no loop needed
Dim wkstr As String
wkstr = ActiveSheet.Name
Worksheets.Select
Range("A1").Select
Sheets(wkstr).Select
End Sub
___________________________________________________________________________________
_________________
Sub GoTo_nextrow_A() 'ctrl+SHIFT+N ctrl+Enter
'-- Advance to Column A of next row
Cells(ActiveCell.Row + 1, 1).Select
End Sub
___________________________________________________________________________________
_________________

H="Option Explicit: all those little get formulae together"

'-- David McRitchie http://www.mvps.org/dmcritchie/excel/formula.htm


'-- http://www.mvps.org/dmcritchie/excel/code/formula.txt

'-- Directions to install VBA code can be found at


' http://www.mvps.org/dmcritchie/excel/getstarted.htm#modulename
' Install as a new Module {Insert, New Module) (warning not as a class module)
' with name "McRitchie_Formula" by changing name of Module nnn by selecting
' Module nnn if not already selected then get to View, Properties using
' F4 {View, Properties Window} and change the module name.
'
' Also of interest see http://www.mvps.org/dmcritchie/excel/rightclick.htm
' to add GetFormula_sub to context (right-click) menu.

Function GetFormula(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Application.Volatile = True
GetFormula = cell.Formula
End Function

Function GetFormulaD(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Application.Volatile = True
GetFormulaD = cell.Address(0, 0) & ": " & cell.Formula
End Function

Function GetFormat(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
' Application.Volatile = True
On Error Resume Next
GetFormat = ""
GetFormat = cell.NumberFormat
End Function

Function GetFormatD(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
' Application.Volatile = True
On Error Resume Next
GetFormatD = ""
GetFormatD = cell.Address(0, 0) & ": " & cell.NumberFormat
End Function

Function GetFormulaI(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Application.Volatile = True
If VarType(cell) = 8 And Not cell.HasFormula Then
GetFormulaI = "'" & cell.Formula
Else
GetFormulaI = cell.Formula
End If
If cell.HasArray Then _
GetFormulaI = "{" & cell.Formula & "}"
End Function
Function GetFormulaID(cell As Range) As String
'Application.Volatile = True
Dim GetFormulaI As String
If VarType(cell) = 8 And Not cell.HasFormula Then
GetFormulaI = "'" & cell.Formula
Else
GetFormulaI = cell.Formula
End If
If cell.HasArray Then _
GetFormulaI = "{" & cell.Formula & "}"
GetFormulaID = cell.Address(0, 0) & ": " & GetFormulaI
End Function

Function GetFormulaX(cell As Range) As String


'-- to be used in another formula =indirect(xx) + insdirect(yy)
'Application.Volatile = True
If IsEmpty(cell) Then
GetFormulaX = """"""
ElseIf VarType(cell) = 8 And Not cell.HasFormula Then
If Left(cell, 1) = "'" Then
GetFormulaX = """" & Mid(cell, 2) & """"
Else
GetFormulaX = """" & cell & """"
End If
ElseIf cell.HasFormula Then
GetFormulaX = Mid(cell.Formula, 2)
Else
GetFormulaX = cell.Formula
End If
End Function
Function getFontName(cell As Range) As String
getFontName = cell.Font.Name 'D.McR formula.htm
End Function

Function GetText(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
' Application.Volatile = True
On Error Resume Next
GetText = cell.Text
End Function

Function HasFormula(cell)
'created using a suggestion by Nick Manton nickm@sri.com
' http://www.mvps.org/dmcritchie/excel/formula.htm
HasFormula = cell.HasFormula
End Function

Function ShowFormula(cell As Range) As String


Application.Volatile
If cell.HasFormula Then ShowFormula = cell.Formula
End Function
Function FontStyle(cell As Range) As String
'Won't change value until some value on sheet changes
Application.Volatile
FontStyle = cell.Font.FontStyle
End Function

Function CondFormula(myCell As Range, Optional cond As Long = 1) As String


'Bernie Deitrick programming 2000-02-18, modified D.McR 2001-08-07
Application.Volatile
CondFormula = ""
On Error Resume Next
CondFormula = myCell.FormatConditions(cond).Formula1
End Function

Sub FormulaBox()
'David McRitchie 1998-08-12 1999-08-17
' http://www.mvps.org/dmcritchie/excel/formula.htm
'Place material into MsgBox [ctrl+n]
'Will process ranges of one or more columns
'Application.ScreenUpdating = False
Dim MsgBoxx As String
Dim ix As Long
Dim vGetFormulaI As String, xyx As String
MsgBoxx = "First Character of " _
& Selection.Item(ix).Address(0, 0) & " is """ _
& Left(ActiveCell.Value, 1) & """ =CHR(" _
& Right("0000" & Asc(ActiveCell.Value), 4) & ") or Hex=x'" _
& Hex(Asc(ActiveCell.Value)) & "'" & Chr(10) _
& "Last Character is """ & Right(ActiveCell.Value, 1) _
& """ =CHR(" _
& Right("0000" & Asc(Right(ActiveCell.Value, 1)), 4) & ") or Hex=x'" _
& Hex(Asc(Right(ActiveCell.Value, 1))) & "'" & Chr(10) _
& ActiveCell.Font.Name & " " & ActiveCell.Font.Size _
& " " & ActiveCell.Font.FontStyle _
& ", color: " & ActiveCell.Font.ColorIndex _
& " interior: " & ActiveCell.Interior.ColorIndex _
& Chr(10) & Chr(10)

For ix = 1 To Selection.Count
'Selection.Item(ix).NoteText _ ...
vGetFormulaI = ""
If VarType(Selection.Item(ix)) = 8 Then
vGetFormulaI = "'" & Selection.Item(ix).Formula
Else
vGetFormulaI = Selection.Item(ix).Formula
End If
If Selection.Item(ix).HasArray Then _
vGetFormulaI = "{" & Selection.Item(ix).Formula & "}"

'include below if VarType wanted -- don't include for distribution


' & " " & VarType(Selection.Item(ix)) _ ..
MsgBoxx = MsgBoxx _
& Selection.Item(ix).Address(0, 0) _
& ": " & vGetFormulaI _
& Chr(10) & " " & Selection.Item(ix).NumberFormat & Chr(10)

Next
MsgBoxx = MsgBoxx & Chr(10) & "***" _
& Chr(10) & _
LCase(ActiveWorkbook.FullName) & " " & ActiveSheet.Name
'to verify you've seen everything
xyx = MsgBox(MsgBoxx, , _
"FormulaBox: Formula & Format & Text for " _
& Selection.Count & " selected cells")
'Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________

Sub FormulaSheet()
'Print information for each non empty cell DMcRitchie 2001-04-30
'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'Also see John Walkenbach -- Tip 37 which is formulas only
' ( track this down and see if it was a hyperlink )

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim irow As Long, cell As Range
Dim oSheet As Worksheet, nSheet As Worksheet
Dim oCells As Range
irow = 1
Set oSheet = ActiveSheet
Set nSheet = ActiveWorkbook.Worksheets.Add
nSheet.Name = oSheet.Name & " content at " _
& Format(Now(), "hhmss")
nSheet.Cells(1, 1) = "Cell"
nSheet.Cells(1, 2) = "Text"
nSheet.Cells(1, 3) = "Value"
nSheet.Cells(1, 4) = "Formula"
nSheet.Cells(1, 5) = "NumberFormat"

For Each cell In oSheet.UsedRange


If Not IsEmpty(cell) Then
irow = irow + 1
Cells(irow, 1).Value = cell.Address(0, 0)
Cells(irow, 2).Value = "'" & cell.Text
Cells(irow, 3).Value = cell.Value
Cells(irow, 4).Value = "'" & cell.Formula
Cells(irow, 5).Value = "'" & cell.NumberFormat
End If
Next cell
Columns("A:F").EntireColumn.AutoFit
Rows("1:1").Font.Bold = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________

Function UseFormula(cell)
'David McRitchie Jul 20, 1998 if this is valid will be
'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
UseFormula = Application.Evaluate(cell.Formula)
'If "'" <> Left(cell.formula, 1) Then UseFormula = "'" & cell.formula
End Function

Function UseFormula2(cell As Range) As String


'Documented in http://www.mvps.org/dmcritchie/excel/formula.htm
'UseFormula Jul 20, 1998, UseFormula2 Jun 13, 2000
'Application.Volatile = True -- DO NOT DO THIS
'GetFormula = cell.Formula
If Trim(cell.Value) = "" Then
UseFormula2 = ""
Exit Function
ElseIf Left(cell.Value, 1) = "=" Then
UseFormula2 = Application.Evaluate(cell.Formula)
Exit Function
Else
UseFormula2 = "'#bad formula"
End If
End Function

Function UseSameAs(cell As Range)


'-- Use the same Formula as used in the referenced cell
'-- http://mvps.org/dmcritchie/excel/formula.htm#usesameas 2005-09-03 .excel
Application.Volatile
If cell.HasFormula Then
UseSameAs = Application.Caller.Parent.Evaluate(cell.Formula)
Else '-- needed if constant looks like a cell address
UseSameAs = cell.Value
End If
End Function

Function ISBOLD(cell As Range) As Boolean


If cell.Font.Bold Then ISBOLD = True
End Function

'-- The following macros have been moved to McRitchie_insrtrow (insrtrow.txt)


'-- InsertRowsAndFillFormulas(Optional vRows As Long = 0)
'-- InsertBlankRows()
'-- InsertBlankRowBeforeLast()
'-- Guarantee2RowsAfterA_values()

Sub WhereAmI()
'D.McRitchie, pathname.htm, excel.misc 1999-07-30
MsgBox ActiveWorkbook.FullName & Chr(10) & _
"Microsoft Excel is using " & Application.OperatingSystem
End Sub
___________________________________________________________________________________
_________________
Sub Euro_Format()
Selection.NumberFormat = _
"_(�* #,##0.00_);_(�* (#,##0.00);_(�* "" - ""???_);_(@_)"
End Sub
___________________________________________________________________________________
_________________
Function showAlign(cell As Range) As String
'David McRitchie, 2004-09-15
' based on http://www.mvps.com/dmcritchie/excel/code/xl2htmlx.txt
Dim ca As String
If Trim(Replace(cell.Text, Chr(160), "")) = "" Then
ca = "N/A"
ElseIf cell.HorizontalAlignment = -4138 Then
ca = "Left"
ElseIf cell.HorizontalAlignment = -4108 Then
ca = "Center"
ElseIf cell.HorizontalAlignment = -4131 Then
ca = "Left"
ElseIf cell.HorizontalAlignment = -4152 Then
ca = "Right"
ElseIf IsNumeric(cell) Then
ca = "Right"
Else
ca = "Left"
End If '-4138 left, -4108 center, -4152 right, HTML default left
showAlign = ca
End Function

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Thread: Clear Memory With Vba Code (and open and close excel from beyond, for
webquery multiple)"

Thread Tools
Search Thread
September 27th, 2006 #1 DOC
Senior Member
Join Date
29th July 2006
Posts
224
Clear Memory With Vba Code

'I have a workbook, with coding that opens many workbooks and performs
' several updates in each one, it seems that for some reason there is
' build up of memory with big files etc, is there a way with code that
' after each workbook has been updated and before the master workbook
' loads the next workbook for update that i can clear all memory,
' similar to closing excel down completly and reopening ?

'I don't think that you will find a solution to the issue that you are
' talking about. I've had simmilar issues in the past and have paid
' more attention to releasing objects when done with them. However, on
' some of my projects and the most pronounced ones are those that
' query databases. If I do many queries, by that I mean I try to run
' many updates to get missed data I find that in the TASK manager the
' memory used for XL continually grows, and that even when the updates
' are done and XL is idle memory (resources ) is not being returned to
' the OS. Now by excessive I mean that typically when my XL starts it
' states 30,000 K and that when I've ran alot of updates I've had that
' number up to 500,00K. The real issue with that is that it then takes
' forever for XL to close and then return that space back to the OS.

But nothing I've done seems to get rid of that situation. Maybe Jack will have more
information.
Regards,
Barry

My Favorite New Thing:


Dynamic Named Ranges

The alternative for


"Press Any Key To Continue."

and we all have one we'd like to use it on

Re: Clear Memory With Vba Code

Originally Posted by Jack in the UK


DOC
'Post up Your opening VBA codes buddy? Please use VBA Code tags thou
'jiuk
'Jack, i am not sure you will get much from this, the frst sub control
' pannel, opens 9 subs, one is lited below, and the others are the
' same, theses subs open and check for dates then runs a macro within
' that open workbook, the coding in those workbooks downloads web page
' data and it can depending on the size of the file take a lot of time
' and copy's multiple data over, in a prevous post re data from the
' web i was able to improve the workings of these files, and if i run
' them 1 by 1 they are fine ( ie shut down excel and open for the next
' one ) but when i run them together as in the above code it will just
' hang and the system stops, where i need to ctrl/alt del to get out
' of the system and start again.

'it seems if excel is fresh ie closed and re opened the problem is not
' there hence a way to clear the memory between the 9 updates.

'VB:
Sub CONTPAN()
'
Range("i2").Value = Range("j2").Value
Range("i2").NumberFormat = "dd/mm/yyyy"

' DATA SETS


RJ
' update 2 through to update 9

ActiveWorkbook.Save
Application.Quit
End Sub
___________________________________________________________________________________
_________________
Sub RJ()
MYTIME
Range("D10").Select
If Range("I2").Value = ActiveCell.Offset(0, 6).Value Then
Exit Sub
Else
If ActiveCell.Offset(0, -1).Value <> "Y" Then
Exit Sub
End If
MYDAYS = ActiveCell.Offset(0, 1).Value
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Application.CommandBars("Web").Visible = False
If Range("p3").Value > Range("P28").Value Then
Range("L9").Value = MYDAYS
End If
Application.Run "'1.JTDATA V9-5.XLS'!SELECTUPDATE"
''' GET DATE HERE
MYRECORDS = Range("C11").Value
MYDAY = Range("S1").Value
MYMONTH = Range("p2").Value
MYYEAR = Range("P1").Value
MYTIMENOW = Range("L27").Value
ActiveWorkbook.Save
ActiveWindow.Close
ActiveCell.Offset(0, 5).Value = MYYEAR
ActiveCell.Offset(0, 6).Value = MYDAY
ActiveCell.Offset(0, 7).Value = MYMONTH
ActiveCell.Offset(0, 7).NumberFormat = "dd/mm/yyyy"
ActiveCell.Offset(0, 9).Value = MYRECORDS
ActiveCell.Offset(0, 11).Value = MYTIMENOW
End If
End Sub
___________________________________________________________________________________
_________________

'VB:
Sub MYTIME()
Range("i2").Value = Range("j2").Value
Range("i2").NumberFormat = "dd/mm/yyyy"
End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Thread: Saving to another sheet/next blank cell,row"

'possible to create a Macro or something that will transfer a


' selection of date both numbers and text to a different sheet but
' when you run the macro or alternative it creates it on the next
' available empty line as to not over write information already saved.

'Kind Regards
'Mark

'Location
'Sutton Coldfield - England
'Posts
'8,676
'Re: Saving to another sheet
'try this

'VB:
Sub CopyToLastCell()
'copy values to next blank cell in destination sheet col A
Dim rngMyRange As Range
Set rngMyRange = Sheets("DestinationSheet").Range("A65536").End(xlUp)(2)
Range("B10:J10").Copy
With rngMyRange
.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End With
Application.CutCopyMode = False
Set rngMyRange = Nothing
End Sub
___________________________________________________________________________________
_________________
'you just need toamend the ranges / sheet names to match your own
'Kind Regards, Will Riley
'Re: Saving to another sheet
'I've managed to get the code working but it comes out down the page
' is it possible to get it across and if so which bit do i need to
' change?

'Kind Regards
'Mark
'Ads By Ozgrid
'Compare Excel | Trading Add-ins For Excel | VBA Code Print | Business
' Spreadsheets | XL Dashboard Reports | XL Sparkmaker

'Downloads For Excel | Convert Excel Into... | Merge Excel Files |


' Produce Clean, Efficient & Fast VBA Code | Convert/Migrate Databases
'Reply With Quote
'March 24th, 2005 #8 Will Riley

'Jedi
'Join Date
'28th January 2003
'Location
'Sutton Coldfield - England
'Posts
'8,676
'Re: Saving to another sheet
'Sorry, had to head off home.
'Try this

'VB:
Option Explicit

Sub Multi_array_Paste()
Dim rngUnion As Range, rngPaste As Range
Dim myArray() As Variant
Dim x As Variant
Dim i As Integer

'Set the range to loop through


With Worksheets("Sheet1")
Set rngUnion = Union(.Range("C4:C10,C13:C14"), .Range("D4:D15"))
End With
'Loops through the ranges
For Each x In rngUnion
Redim Preserve myArray(i)
'Add an item to the array
myArray(i) = x.Value
i = i + 1
Next x

'paste the array to next row in sheet2


With Worksheets("Sheet2")
Set rngPaste = .Range("A65536").End(xlUp)(2)
rngPaste.Resize(1, 21) = myArray
End With
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="code I could use., Cell Locking automatically"

'For e.g. I could potentially lock the cells which have formulas in
' them, and hopefully apply VBA code so that those cells cannot be
' selected.

'Thanks,

'KF
'Ads By Ozgrid
'Compare Excel | Trading Add-ins For Excel | VBA Code Print | Business
' Spreadsheets | XL Dashboard Reports | XL Sparkmaker

'Downloads For Excel | Convert Excel Into... | Merge Excel Files |


' Produce Clean, Efficient & Fast VBA Code | Convert/Migrate Databases
'Reply With Quote
'June 24th, 2004 #4 Will Riley
'Jedi
'Join Date
'28th January 2003
'Location
'Sutton Coldfield - England
'Posts
'8,676
'This may give you the general idea....

'VB:
'Sub LockProtectandHide()
' 'first we unprotect & clear existing setup
' With ActiveSheet
' .Unprotect Password:="password"
' With .Cells
' .Locked = False
' .FormulaHidden = False
' End With
' 'then we can lock the specific cells we want
' With .Range("B6:E8,B2:E4")
' .Locked = True
' .FormulaHidden = True
' End With
' .Protect DrawingObjects:=True, _
' Contents:=True, _
' Scenarios:=True, _
' Password:="password"
' End With
'End Sub
___________________________________________________________________________________
_________________

'The above code will leave everything on the sheet unlocked & unhidden
' apart from the ranges B6:E8 and B2:E4 - you would need to adjust
' these ranges to suit your own... the protection uses a password as
' well although this is optional...
'Kind Regards, Will Riley

'Web Presence:
'Personal: The Trouble With Data
'LinkedIn: Will Riley
'Reply With Quote
'June 24th, 2004 #5 kfotedar
'Member
'Join Date
'24th June 2004
'Posts
'48
'WillR:

'I used the code below which works fine only thing is that it is
' designed to work for just one cell.i.e. A1. Is it possible to make
' it work for a number of cells or even like a range name. I tried
' that didn't work.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


If Target.Address(0, 0) = "A1" Then
Range("b1").Select
MsgBox "Sorry this cell is locked", vbInformation, Target.Address(0, 0)
End If
End Sub
___________________________________________________________________________________
_________________

'iNSTEAD OF "If Target.Address(0, 0) = "A1" Then"

'i TRIED "If Target.Address(0, 0) = Range("Cell_Formula") Then"

'It did not work, where did i Go wrong?

'Still can't really understand your aversion to locking/protecting the


' sheet... but this will probably do what you want

'VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngLocked As Range
Set rngLocked = Intersect(ActiveCell, Range("Cell_Formula"))
If Not rngLocked Is Nothing Then
Range("B1").Select
MsgBox "Sorry this cell is locked", vbInformation, _
Target.Address(0, 0)
End If
Set rngLocked = Nothing
'Kind Regards, Will Riley

'June 24th, 2004 #7 Aaron Blood


'OzMVP
'Join Date
'10th February 2003
'Location
'Palm Beach, Florida
'Posts
'1,590
'I have a little example you can look at:
'http://www.xl-logic.com/xl_files/vba/forbid_range.zip (notfound!2012-05-01
22:05:19)

'It's far from perfect... Lots of ways to potentially defeat it if you


' think about it. If anyone cares to improve upon it let me know and
' I'll update it.
'Sub All_Macros(Optional control As Variant)
'Reply With Quote
'June 25th, 2004 #8 kfotedar
'Member
'Join Date
'24th June 2004
'Posts
'48
'

'Thanks WILLR!

'The code worked, the reason I don't want to go the sheet protection
' route is because that locks other features on the worksheet. The
' code you gave worked like a charm.

'AARON:

'Your code was good too, but I could not get it to work , I guess it's
' beacuse my range (formula_cell) is non-contigous, while your range
' in the example you provide was contigous? Just my guess. But thanks,
' for continous ranges will use what you provided.
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Excel VBA: Create a List of Hyperlinks to List all Excel Workbooks"

Sub HyperlinkXLSFiles()

'See Also: Loop Through Folder

'Create a Hyperlinked List of Excel Workbook File Names

'With the use of Excel VBA Macro code we can create a list of
' Hyperlinked Excel Workbook names on any Excel Worksheet. The code
' below can be used on any version of Excel, 2000 or higher. The only
' changes needed are to the file paths used. The part of the code that
' reads: .Filename = "Book*.xls" has been commented out but can be
' uncommented if you wish to restrict the list to that of specific
' Excel Workbook name. Note also the code 'as is' restricts the list
' to only Excel Workbooks. However, this can be any of the File types
' listed below;

'MsoFileType can be one of these MsoFileType constants


'msoFileTypeAllFiles
'msoFileTypeBinders
'msoFileTypeCalendarItem
'msoFileTypeContactItem
'msoFileTypeCustom
'msoFileTypeDatabases
'msoFileTypeDataConnectionFiles
'msoFileTypeDesignerFiles
'msoFileTypeDocumentImagingFiles
'msoFileTypeExcelWorkbooks
'msoFileTypeJournalItem
'msoFileTypeMailItem
'msoFileTypeNoteItem
'msoFileTypeOfficeFiles
'msoFileTypeOutlookItems
'msoFileTypePhotoDrawFiles
'msoFileTypePowerPointPresentations
'msoFileTypeProjectFiles
'msoFileTypePublisherFiles
'msoFileTypeTaskItem
'msoFileTypeTemplates
'msoFileTypeVisioFiles
'msoFileTypeWebPages
'msoFileTypeWordDocuments

'Ensure the active Worksheet at the time of running the code is clean
' so as to not over write existing data.

Dim lCount As Long

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Application.EnableEvents = False

On Error Resume Next

With Application.FileSearch

.NewSearch

'Change path to suit

.LookIn = "C:\MyDocuments\Testings"

.FileType = msoFileTypeExcelWorkbooks

' .Filename = "Book*.xls"

If .Execute > 0 Then 'Workbooks in folder

For lCount = 1 To .FoundFiles.Count 'Loop through all.

ActiveSheet.Hyperlinks.Add Anchor:=Cells(lCount, 1), Address:=


_

.FoundFiles(lCount), TextToDisplay:= _

Replace(.FoundFiles(lCount), "C:\MyDocuments\Testings\", "")

Next lCount

End If

End With

On Error GoTo 0

Application.ScreenUpdating = True

Application.DisplayAlerts = True

Application.EnableEvents = True

End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Excel VBA: Loop Through a Folder of Excel Workbooks With the FileSearch Method"

'See Also: Excel 2007 Alternative To File Search | Loop Through


' Worksheets | Create a Hyperlinked List of Excel Workbook

'Loop Through a Folder of Excel Workbooks

'With the use of Excel VBA Macro code we can loop through a Folder on
' ones Hard-drive and work on all Excel Workbooks within it. The code
' below can be used on Excel 97 - Excel 2003 (For Excel 2007, see
' Excel 2007 Alternative To File Search). The only changes needed are
' to the file paths used. The part of the code that reads: .Filename =
' "Book*.xls" has been commented out but can be uncommented if you
' wish to restrict the list to that of specific Excel Workbook name.
' Note also the code 'as is' restricts the list to only Excel
' Workbooks. However, this can be any of the File types listed below;

Sub RunCodeOnAllXLSFiles()
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

On Error Resume Next


Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "C:\MyDocuments\TestResults"
.FileType = msoFileTypeExcelWorkbooks
'Optional filter with wildcard
'.Filename = "Book*.xls"
If .Execute > 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through all
'Open Workbook x and Set a Workbook variable to it
Set wbResults =
Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)

'DO YOUR CODE HERE

wbResults.Close SaveChanges:=False
Next lCount
End If
End With
On Error GoTo 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
___________________________________________________________________________________
_________________

'MsoFileType can be one of these MsoFileType constants

'msoFileTypeAllFiles
'msoFileTypeBinders
'msoFileTypeCalendarItem
'msoFileTypeContactItem
'msoFileTypeCustom
'msoFileTypeDatabases
'msoFileTypeDataConnectionFiles
'msoFileTypeDesignerFiles
'msoFileTypeDocumentImagingFiles
'msoFileTypeExcelWorkbooks
'msoFileTypeJournalItem
'msoFileTypeMailItem
'msoFileTypeNoteItem
'msoFileTypeOfficeFiles
'msoFileTypeOutlookItems
'msoFileTypePhotoDrawFiles
'msoFileTypePowerPointPresentations
'msoFileTypeProjectFiles
'msoFileTypePublisherFiles
'msoFileTypeTaskItem
'msoFileTypeTemplates
'msoFileTypeVisioFiles
'msoFileTypeWebPages
'msoFileTypeWordDocuments

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^
H="Thread: Update Fields From .txt File"

'
'Hi,

'I need to update some fields in my excel sheet from a .txt file
' (comma or space separated), based on matching values of a key field
' in both files. I do not want to import the file into excel and do a
' vlookup.

'I am thinking of a macro that prompts the user for the file location
' ( txt file) and then scans the txt file and updates the fields.

'Would anyone know how to go about doing this or have any code I can
' use?
'Re: Update Fields From .txt File
'if you know at what position in a line of the text file your key word
' is to be found and also the the position of the value to be written
' in your xl file then you can use something like this:

'VB:
FName = path_and_filename_of_txt_file
Open FName For Input Access Read As #1
While Not EOF(1)
Line Input #1, WholeLine
If Mid(WholeLine, 2, 6) = SEARCHKEY Then
Cells(RowNdx, ColNdx).Value = Mid(WholeLine, 22, 7)
RowNdx = RowNdx + 1
End If
Wend

'The above writes every found value onto a new line. That might have
' to be altered for you of course.
'In formulae, depending on your locale, you might have to replace ;
' with , or vice versa.
'Reply With Quote
'March 19th, 2007 #3 aadarsh
'Senior Member
'Join Date
'12th January 2005
'Location
'Singapore
'Posts
'201
'Re: Update Fields From .txt File

'
'i have been able to use this code. however, need help to solve 2 more
' problems:-

'1) what is the code to close a text file?


'2) I need to simulatneously open 2 text files and read data from
' them. is this possible?

'Thanks!
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_

H="[Solved] Formulas to create hyperlinks"

'
'I&#039;m trying to create a hyperlink to another cell in the same
' workbook by creating the hyperlink destination address using
' formulas in other cells. This works perfectly in a new workbook but
' fails as soon as the workbook is saved. I feel like I&#039;ve tried
' everything including specifying the route using the
' =CELL("filename") formula. Any ideas what I&#039;m doing wrong?

'I&#039;ve used this appoach in the past when I need to create dynamic
' formula-driven hyperlinks within a workbook.
'Instead of hyperlinks I use VBA & the Worksheet_BeforeDoubleCclick
' event. If your links are on sheet1 then place this code into the
' sheet1 module.

'In this example a &#039;hyperlink&#039; occurs if a cell is


' doubleclicked & is blue & underlined.

'VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean
#41;
goto_sheet = 'formula
goto_cell = 'formula
On Error Resume Next
Select Case Target.Font.Underline
Case xlUnderlineStyleSingle
If Target.Font.ColorIndex = 41 Then
Application.Goto Worksheets(goto_sheet).Range(goto_cell)
End If
End Select
End Sub
___________________________________________________________________________________
_________________

'This example is similar but has the formulas (to derive sheetname &
' cell name) in coumns D&E of the activerow.

'VB:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean


#41;

sheet_col = "D"
cell_col = "E"
goto_sheet = Cells(ActiveCell.Row, sheet_col).Value
goto_cell = Cells(ActiveCell.Row, cell_col).Value
On Error Resume Next
Select Case Target.Font.Underline
Case xlUnderlineStyleSingle
If Target.Font.ColorIndex = 41 Then
Application.Goto Worksheets(goto_sheet).Range(goto_cell)
End If
End Select
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="makes a sheet tab equal a cell reference in a different worksheet"

'eg sheet1 a4 = cossie how do i make sheet4 sheet tab name equal
' cossie?
'
' Feb 19th, 2003, 08:51 PM #2
'phantom1975
'MrExcel MVP
'

'
'Join Date: Jun 2002
'Location: Omaha, Nebraska
'Posts: 3,910

'I'm afraid that there is no really good way to do what you would like
' to do. You can create a macro to do this, but it would only work
' once. For example:

'Sheets("Sheet4").Name = Sheets("Sheet1").Range("A4").Value

'This would work fine the first time. After that, "Sheet4" no longer
' exists. You would need something a bit more elaborate! First of all,
' you would need to pick a cell in Sheet4 to put the following formula:

'=RIGHT(CELL("filename",A1),LEN(CELL("filename",A1))-SEARCH("]",
' CELL("filename",A1)))

'Then you would need to name this cell using the NAMED CELL RANGE.
' Let's call it SheetNameValue. You can then use the following code in
' Sheet1:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$4" Then

Sheets([SheetNameValue].Value).Name = Target.Value

End If

End Sub
___________________________________________________________________________________
_________________
'Does this help?
'Yes!

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^
H="WriteFormulasToWord"

'a macro that actually pulled the formulas and placed them in a Word
' document for you. The following Excel macro will do just that:

Sub WriteFormulasToWord()
Dim Wrd As New Word.Application
Dim CellTxt As String
Dim CellAddr As String
Dim SRow As Long
Dim SCol As Long

Wrd.Visible = True
Wrd.Documents.Add

Wrd.Selection.TypeText Text:="List of the Formulas of Sheet """ _


& ActiveSheet.Name & """ in Workbook """ _
& ActiveWorkbook.Name & """."
Wrd.Selection.TypeText Text:=vbCrLf & vbCrLf

'Change the following line to pick the number of columns


For SCol = 1 To 5
'Change the following line to pick the number of rows
For SRow = 1 To 10
If Cells(SRow, SCol).HasFormula Then
CellAddr = Chr(64 + SCol) & Trim(Str(SRow)) & vbTab
CellTxt = ActiveSheet.Cells(SRow, SCol).Formula
Wrd.Selection.TypeText Text:=CellAddr & CellTxt
Wrd.Selection.TypeText Text:=vbCrLf
End If
Next SRow
Wrd.Selection.TypeText Text:=vbCrLf
Next SCol
End Sub
___________________________________________________________________________________
_________________
'There are a couple of things to note in this macro. First of all, you
' can change the range of rows and columns over which the macro works
' by changing the noted For statements that use both SCol and SRow. In
' the example shown above, the macro pulls formulas from columns 1
' through 5 (A through E) and rows 1 through 10.

'In addition, this macro will not work properly unless you set up
' Excel macros to handle references to Word objects. You do that by
' following these steps within the VBA Editor:
'Choose References from the Tools menu. VBA displays the References
' dialog box. (See Figure 3.)

' Figure 3. The References dialog box.


'Scroll through the list of references until you see one called
' Microsoft Word Object Library. (There may be a version number
' included in the reference name, such as Microsoft Word 11.0 Object
' Library.)
'Make sure the check box to the left of the object library is selected.
'Click on OK.
'An advantage to using a macro to actually pull your formulas is that
' you can customize exactly what is placed in the Word document. In
' the case of this macro, the address of the cell is inserted,
' followed by a tab character, and then the actual formula. You could
' just as easily change the information inserted to be anything you
' need in your particular instance.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Creating a List of ALL Formulas (Using Special.Cells)"

'Most users have discovered that Excel has an option that lets you
' display formulas directly in their cells: Choose Tools Options,
' click the View tab, and select the Formulas checkbox. However, Excel
' doesn't provide a way to generate a concise list of all formulas in
' a worksheet. The VBA macro below inserts a new worksheet, then
' creates a list of all formulas and their current values.

'NOTE:
'The Power Utility Pak includes a more sophisticated version of this
' subroutine, plus several other auditing tools.

'To use this subroutine:


'Copy the code below to a VBA module. You can also store it in your
' Personal Macro Workbook, or create an add-in.
'Activate the worksheet that contains the formulas you want to list.
'Execute the ListFormulas subroutine. The subroutine will insert a new
' worksheet that contains a list of the formulas and their values.
'The ListFormulas Subroutine

Sub ListFormulas()
Dim FormulaCells As Range, Cell As Range
Dim FormulaSheet As Worksheet
Dim Row As Integer

' Create a Range object for all formula cells


On Error Resume Next
Set FormulaCells = Range("A1").SpecialCells(xlFormulas, 23)

' Exit if no formulas are found


If FormulaCells Is Nothing Then
MsgBox "No Formulas."
Exit Sub
End If

' Add a new worksheet


Application.ScreenUpdating = False
Set FormulaSheet = ActiveWorkbook.Worksheets.Add
FormulaSheet.Name = "Formulas in " & FormulaCells.Parent.Name

' Set up the column headings


With FormulaSheet
Range("A1") = "Address"
Range("B1") = "Formula"
Range("C1") = "Value"
Range("A1:C1").Font.Bold = True
End With

' Process each formula


Row = 2
For Each Cell In FormulaCells
Application.StatusBar = Format((Row - 1) / FormulaCells.Count, "0%")
With FormulaSheet
Cells(Row, 1) = Cell.Address _
(RowAbsolute:=False, ColumnAbsolute:=False)
Cells(Row, 2) = " " & Cell.Formula
Cells(Row, 3) = Cell.Value
Row = Row + 1
End With
Next Cell

' Adjust column widths


FormulaSheet.Columns("A:C").AutoFit
Application.StatusBar = False
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

H="Code To List Formulae of code-specified region"

' User Name Remember Me?


'Password

'Register FAQ Calendar Today's Posts Search Search MrExcel


' Online Store Lost Password

'Excel Questions All Excel/VBA questions - formulas, macros, pivot


' tables, general help, etc. Please post to this forum in English only.

' Page 2 of 2 < 1 2

' Thread Tools Display Modes


' Jan 2nd, 2003, 05:27 PM #11
'Excello
'New Member
'
'Join Date: Aug 2002
' Posts: 43
' Hi,

'You could instruct your users to put the morefunc folder in their
' home directory and to activate the add-in from that folder.

'
' Jan 2nd, 2003, 10:06 PM #13
'Tom Urtis
'MrExcel MVP
'Join Date: Feb 2002
'Location: San Francisco, California USA
' Posts: 10,569
' Perhaps this macro may help. Place it in a standard VBA module, then
' activate the sheet containing the formulas, and run the macro.

' It will create a new sheet, list your formulas, and separate them by
' sheet name and cell reference with the help of Andrew Poulsom's
' formulas. The root idea for the macro structure came from something
' similar posted by Dave Peterson last year, so thanks to him also.

' Tested on XL2K2 XP.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub ListFormulas()

Dim SourceSheet As Worksheet


Dim cell As Range
Dim counter As Long, LastRow As Long, iRow As Long, AllFormulas As Long

Set SourceSheet = ActiveSheet

Application.ScreenUpdating = False

With Worksheets.Add(after:=Sheets(Sheets.count))

Application.DisplayAlerts = False
On Error Resume Next
Worksheets(Left(SourceSheet.Name, 22) & "_Formulas").Delete
On Error GoTo 0
Application.DisplayAlerts = True

.Name = Left(SourceSheet.Name, 22) & "_Formulas"


.Range("A1").Value = "Formulas on Sheet " & SourceSheet.Name & ":"
.Range("C:D").NumberFormat = "@"

Range("A3").Value = "Cell Count"


Range("B3").Value = "Cell Address"
Range("C3").Value = "Formula, standard"
Range("D3").Value = "Formula, RC"
Range("E3").Value = "Sheet name, standard"
Range("F3").Value = "Cell ref, standard"
Range("G3").Value = "Sheet name, RC format"
Range("H3").Value = "Cell ref, RC format"
Range("A1,A3:H3").Font.Bold = True

counter = 0
On Error Resume Next
AllFormulas = SourceSheet.Cells.SpecialCells(xlCellTypeFormulas).Cells.count
For Each cell In SourceSheet.Cells.SpecialCells(xlCellTypeFormulas)
.Range("B4").Offset(counter, 0).Value = cell.Address(0, 0)
.Range("C4").Offset(counter, 0).Value = cell.Formula
.Range("D4").Offset(counter, 0).Value = cell.FormulaR1C1
counter = counter + 1
Next cell
On Error GoTo 0

Range("B3").CurrentRegion.Sort Key1:=.Range("D3"), Header:=xlYes

LastRow = .Cells(.Rows.count, 2).End(xlUp).Row


For iRow = LastRow To 4 + 1 Step -1
If .Cells(iRow, 4).Value = .Cells(iRow - 1, 4).Value Then
.Cells(iRow - 1, 2).Value = .Cells(iRow - 1, 2).Value & ", " & .Cells(iRow,
2).Value
.Rows(iRow).Delete
End If
Next iRow

With .Range("A4:A" & .Cells(.Rows.count, 2).End(xlUp).Row)


.Formula = "=len(B4)-len(substitute(B4,"","",""""))+1"
.Value = .Value
End With

Range("E4", Range("C65536").End(xlUp).Offset(0, 2)).Formula =


"=IF(ISERROR(SUBSTITUTE(MID(RC[-2],2,FIND(""!"",RC[-2],1)-
2),""'"","""")),"""",SUBSTITUTE(MID(RC[-2],2,FIND(""!"",RC[-2],1)-2),""'"",""""))"
Range("F4", Range("D65536").End(xlUp).Offset(0, 2)).Formula = "=RIGHT(RC[-
3],LEN(RC[-3])-FIND(""!"",RC[-3],1))"
Range("G4", Range("E65536").End(xlUp).Offset(0, 2)).Formula =
"=IF(ISERROR(SUBSTITUTE(MID(RC[-3],2,FIND(""!"",RC[-3],1)-
2),""'"","""")),"""",SUBSTITUTE(MID(RC[-3],2,FIND(""!"",RC[-3],1)-2),""'"",""""))"
Range("H4", Range("F65536").End(xlUp).Offset(0, 2)).Formula = "=RIGHT(RC[-
4],LEN(RC[-4])-FIND(""!"",RC[-4],1))"

.Range("A:A").ColumnWidth = 10
.Range("B:H").Columns.AutoFit
.Rows.AutoFit

Application.Goto Range("A1"), True


Application.Goto Range("A4"), False
ActiveWindow.FreezePanes = True

End With

SourceSheet.Activate
Application.Goto Range("A1"), True
Application.ScreenUpdating = True

End Sub
___________________________________________________________________________________
_________________
' __________________
'Tom Urtis
'Microsoft MVP - Excel
'
' Jan 3rd, 2003, 02:57 AM #14
'Andrew Poulsom
'MrExcel MVP
'Moderator
' Here is the VBA equivalent of my formulas:

'Code:
Sub Test()
Dim Rng As Range
Dim Frm As String
Dim WF As WorksheetFunction
Dim Sh As String
Dim Ref As String
' *** Change sheet and range references to suit ***
Set Rng = Worksheets("Sheet1").Range("B5")
Frm = Rng.Formula
Set WF = WorksheetFunction
Sh = WF.Substitute(Mid(Frm, 2, WF.Find("!", Frm, 1) - 2), "'", "")
Ref = Right(Frm, Len(Frm) - WF.Find("!", Frm, 1))
MsgBox "Sheet is " & Sh
MsgBox "Cell reference is " & Ref
End Sub
___________________________________________________________________________________
_________________
'
' Thanks Tom, I will test your code in a later stage.

' Andrew, thanks for the code, but I got an error while running the
' code:

' "Unable to get the Find property of the worksheetfunction class"

' Here is where the code stops:


' Sh = WF.Substitute(Mid(Frm, 2, WF.Find("!", Frm, 1) - 2), "'", "")

' However the Find function is available to VBA, still I don't know
' where is the error with this line. Should we repeat the "WF." before
' each function in theis code?

' Waiting your assistance.

' Excello

'
' Jan 3rd, 2003, 09:08 AM #17
'Andrew Poulsom
'MrExcel MVP
'Moderator
'
'
'
'Join Date: Jul 2002
' Posts: 50,789
' What is the formula in cell B5 on Sheet1? Find will fail if the
' formula does n

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|

H="Extracting File Names from a Path"

'by Allen Wyatt (last updated October 3, 2009)

'Barry has a worksheet in which a column contains many file paths. He


' would like a way to extract just the filename (the part to the right
' of the final backslash) from each path. He wonders if there is a
' quick way to do this without using Text to Columns feature.

'There are several different ways, depending on whether you want to


' use a macro or not.

'If your filenames are all the same length, then you can simply use
' the RIGHT function to pull out the last characters. (This formula
' assumes the full path and file name is in cell A1.)
'=RIGHT(A1,11)

'This assumes that the filename is always 11 characters long, such as


' "text001.txt". If the filename is a different length in each
' instance, then this approach won't work. Instead, you can try this
' formula:
'=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"\",CHAR(1),
'LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))))+1,LEN(A1))

'Note that the formula uses the SUBSTITUTE function twice. In each
' case it replaces the backslashes (\) with something else. The first
' time it replaces all of them with an ASCII value of 1 and the second
' it replaces them with nothing (an empty string) so that it can
' determine how many backslashes were in the original path. The MID
' function is used to locate (with the help of FIND and the SUBSTITUTE
' functions) the location of the last backslash in the path and return
' everything after that point.

'A shorter formula can be used if you are sure that the filename will
' never be more than 99 characters long:
'=TRIM(RIGHT(SUBSTITUTE(A2,"\",REPT(" ",100)),99))

'This formula replaces all the backslashes with 100 spaces, grabs the
' right-most 99 characters from the resulting string (that would be
' the filename with a bunch of spaces in front of it) and then trims
' off all the spaces.

'If you want to use a macro you can create one that steps backward
' through the path until it locates the last backslash. It then
' returns everything after the backslash. The following example starts
' in cell B1, examining everything to the right of the cell (cell A1)
' and then starts pulling out file names. It steps through all the
' cells in column A and puts the file name, if any, in column B.

Sub GetFileName1()
Dim Delimiter As String
Dim Target As String
Dim sFile As String
Dim J As Integer
Dim iDataLen As Integer

Delimiter = "\"
Range("B1").Select
Do While ActiveCell.Offset(0, -1).Value <> ""
Target = ActiveCell.Offset(0, -1).Value
iDataLen = Len(Target)
sFile = "Delimiter Not Found"
For J = iDataLen To 2 Step -1
If Mid(Target, J, 1) = Delimiter Then
sFile = Right(Target, iDataLen - J)
Exit For
End If
Next J
ActiveCell.Formula = sFile
ActiveCell.Offset(1, 0).Select
Loop
End Sub
___________________________________________________________________________________
_________________

'You could also use a much shorter version of a macro, provided you
' can use the Split function. This function was introduced in the
' version of VBA provided with Excel 2000, and it will pull a string
' apart based upon a delimiter you specify and stuff the parts into an
' array. This example shows the solution implemented as a user-defined
' function.

Function GetFileName2(File_Path) As String


Dim Parts

Parts = Split(File_Path, Application.PathSeparator)


GetFileName2 = Parts(UBound(Parts))
End Function
'In this usage the Split function uses as a delimiter whatever path
' separator is appropriate for the system on which Excel is running.
' The last element of the resulting array (determined with the UBound
' function) contains the portion of the original path that is to the
' right of the last path separator�the file name. To use the function,
' put a formula like this in a cell:
'=GetFileName2(A1)

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Finding Unused Names"

'by Allen Wyatt (last updated November 19, 2011)


'

'Richard has a workbook that he's been using for a while, and it has
' quite a few names in it (named ranges, named formulas, etc.). He
' wonders if there is an easy way to find names that are not used at
' all, as he'd like to get rid of those names.

'There is no built-in way to get rid of these unused names. You can,
' however, create a macro that will do the trick for you. This is most
' easily done by using the Find method to figure out which names have
' references that can be "found." If the reference cannot be found,
' then the name is not in use.
Sub RidOfNames()
Dim myName As Name
Dim fdMsg As String

On Error Resume Next


fdMsg = ""
For Each myName In Names
If Cells.Find(What:=myName.Name, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate = False Then
fdMsg = fdMsg & myName.Name & vbCr
ActiveWorkbook.Names(myName.Name).Delete
End If
Next myName
If fdMsg = "" Then
MsgBox "No unused names found in the workbook"
Else
MsgBox "Names Deleted:" & vbCr & fdMsg
End If
End Sub
___________________________________________________________________________________
_________________

'The macro steps through all the elements of the Names collection and
' does a search for each name. If the name cannot be found, then the
' name is deleted. When the macro is completed, it displays a message
' box that lists the names that were removed from the workbook.

'If you would rather not create your own macro, you can opt to use a
' free add-in by Jan Karel Pieterse. The add-in, called Name Manager,
' allows you to (guess what?) manage names better than you can do with
' native Excel. One of the functions it provides is the ability to get
' rid of names that are no longer needed. You can find the add-in here:
'http://www.jkp-ads.com/OfficeMarketPlaceNM-EN.asp

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Forcing a Workbook to Close after Inactivity"

'by Allen Wyatt (last updated November 28, 2011)


'

'Dave wonders if he can force a workbook to close after a certain


' amount of time, provided it is not currently being used. In his
' office people open workbooks that are on the server and then forget
' that they are open. When that occurs, nobody else can edit them, so
' he would like to force workbooks to close if left unattended for 60
' minutes.

'It is possible to do this using macros, but you may not really want
' to do that from a business or user-oriented perspective. For
' instance, let's say that a user has three workbooks open on his
' system, so that comparisons can be made between them. It is possible
' to get "tied up" with two of the workbooks for quite a while, with
' the third one being the one that triggers a shutdown. Excel's VBA
' isn't terribly discriminating�when a workbook is closed, it is
' typically the one which has focus at the current time.

'Further, what do you do with unsaved changes when closing? If you


' save them, you run into the issue that perhaps the user didn't
' intend to save them. If you don't save them, the converse problem
' occurs�perhaps there was a lot of data that needed to be saved. You
' can't have the closing procedure ask if information should be saved;
' that would keep the workbook tied up as surely as keeping it open
' (and unused) would.

'A possible solution is to simply share the workbook. If you enable


' sharing (as discussed in other ExcelTips), then multiple people can
' have the same workbook open at the same time. If one of those people
' leaves it open, then nobody else is inconvenienced because they can
' still open it and, optionally, make changes in the workbook.

'If you decide to go the macro-based route, then the solution is


' rather simple. You need some sort of timer structure (easily
' implemented through use of the OnTime method) and some way to check
' to see if someone is doing something in the workbook.

'To start, add the following code to a standard macro module. Note
' that there are three routines to be added:

Dim DownTime As Date


Sub SetTimer()
DownTime = Now + TimeValue("01:00:00")
Application.OnTime EarliestTime:=DownTime, _
Procedure:="ShutDown", Schedule:=True
End Sub
___________________________________________________________________________________
_________________
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=DownTime, _
Procedure:="ShutDown", Schedule:=False
End Sub
___________________________________________________________________________________
_________________
Sub ShutDown()
Application.DisplayAlerts = False
With ThisWorkbook
.Saved = True
.Close
End With
End Sub
___________________________________________________________________________________
_________________

'These three routines are fairly straightforward. The first two


' respectively turn on the timer and turn it off. Note that these
' routines utilize the DownTime variable, which is declared outside of
' any of the routines. In this way its contents can be utilized in
' multiple routines.

'The third routine, ShutDown, is the one that actually closes the
' workbook. It is only invoked if the OnTime method expires, at the
' end of an hour. It closes the workbook without saving any changes
' that may have been made.

'The next routines (there are four of them) need to be added to the
' ThisWorkbook object. Open the VBA Editor and double-click on the
' ThisWorkbook object in the Project Explorer. In the code window that
' Excel opens, place these routines:

Private Sub Workbook_Open()


Call SetTimer
End Sub
___________________________________________________________________________________
_________________
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call StopTimer
End Sub
___________________________________________________________________________________
_________________
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Call StopTimer
Call SetTimer
End Sub
___________________________________________________________________________________
_________________
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)
Call StopTimer
Call SetTimer
End Sub
___________________________________________________________________________________
_________________

'The first two routines are triggered when the workbook is opened and
' when it is closed; they start the timer and turn it off. The other
' two routines are executed automatically whenever a worksheet is
' recalculated or whenever someone makes a selection in the workbook.
' Both are good indicators that someone is using the workbook (it is
' not inactively open). They stop the timer and then restart it, so
' that the one-hour countdown starts over.

'There is a downside to using a set of macros such as these: you


' effectively eliminate Excel's Undo capability. When a macro is
' executed, the Undo stack is automatically wiped out by Excel. Since
' macros are running with every change made in the workbook, the
' person's changes cannot be undone. (There is no way to get around
' this drawback.)

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_

H="Generating a List of Macros"

'by Allen Wyatt (last updated May 16, 2009)


'

'Once you start writing Excel macros, it is easy to get quite a few of
' them in a workbook. At some point you may want to generate a list of
' macros in your workbook. There is no intrinsic way within Excel to
' create a list of macros. You can, however, create a macro that will
' list your macros. (Sort of sounds redundant, doesn't it?)
'As an example, consider the following macro, which uses the sendkeys
' function to garner all the macro names and place them in a worksheet:

Sub ListMacros()
Dim VBComp As VBComponent
Dim VBCodeMod As CodeModule
Dim oListsheet As Object
Dim StartLine As Long
Dim ProcName As String
Dim iCount As Integer

Application.ScreenUpdating = False
On Error Resume Next
Set oListsheet = ActiveWorkbook.Worksheets.Add
iCount = 1
oListsheet.[a1] = "Macro"

For Each VBComp In ThisWorkbook.VBProject.VBComponents


Set VBCodeMod = ThisWorkbook.VBProject.VBComponents(VBComp.Name).CodeModule
With VBCodeMod
StartLine = .CountOfDeclarationLines + 1
Do Until StartLine >= .CountOfLines
oListsheet.[a1].Offset(iCount, 0).Value = _
.ProcOfLine(StartLine, vbext_pk_Proc)
iCount = iCount + 1

StartLine = StartLine + _
.ProcCountLines(.ProcOfLine(StartLine, _
vbext_pk_Proc), vbext_pk_Proc)
Loop
End With
Set VBCodeMod = Nothing
Next VBComp

Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________

'In order to use this macro, you must make sure you have the Microsoft
' VBA extensibility reference set. To do this, follow these steps:
'In the VBA Editor, choose References from the Tools menu. The
' References dialog box is displayed. (See Figure 1.)

' Figure 1. The References dialog box.


'Scroll through the list of Available References and make sure the
' Microsoft Visual Basic for Applications Extensibility check box is
' selected.
'Close the dialog box.

'When you run the macro, it adds a new worksheet to your workbook, and
' then lists the names of all the macros in all the modules in the
' workbook.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Retrieving Worksheet Names"

Sub GetSheets()

'by Allen Wyatt (last updated October 11, 2008)


'

'If you have a very large number of worksheets in a workbook, you


' might want to retrieve the names of those worksheets and put then on
' their own worksheet. For instance, you may want them in one place so
' you can use them in a table of contents or in some other fashion.
' The following macro, GetSheets, will quickly retrieve the names of
' the worksheets in the current workbook and put them in the first
' column of the current workbook, beginning at cell A1.

Dim J As Integer
Dim NumSheets As Integer

NumSheets = Sheets.Count
For J = 1 To NumSheets
Cells(J, 1) = Sheets(J).Name
Next J
End Sub
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Getting a File Name"

'by Allen Wyatt (last updated October 18, 2008)


'

'If you are writing a VBA macro in Excel, you may have a need to allow
' the user to specify a file they want from the disk. Fortunately, you
' can access the standard Open dialog box from within VBA and use it
' to return just a file name. The following example subroutine shows
' how this is done:

Sub GetFName()
Dim FName As Variant
Dim Msg As String

FName = Application.GetOpenFilename()
If FName <> False Then
Msg = "You chose " & FName
MsgBox Msg
Else
'Cancel was pressed
End If
End Sub
___________________________________________________________________________________
_________________

'When you run this macro, you will see the standard Open dialog box
' used in Excel. The user can select a file, and when they click on
' Open, the file name (including the full path) is assigned to the
' variable FName. If the user clicks on the Cancel button, then FName
' is set equal to False. (Thus the test for that in the code.)

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Selectively Importing Records"

'by Allen Wyatt (last updated May 8, 2010)


'

'Ole ran into a problem importing information into an Excel workbook.


' It seems that the files he needs to import typically have thousands
' and thousands of records in them. Ole doesn't need most of the input
' rows, however, and normally gets rid of them once the records are
' imported into Excel. Ole is looking for a way to get rid of the
' unwanted records during the import process, so that he has less work
' to do when the data is in his workbook.

'There are a couple of different ways that a solution to this problem


' can be approached. One solution is to use Access as your first
' importing step. Access will easily handle the thousands of records
' you want to import�even if there are more records than what you can
' import into Excel. You could import the file into Access, filter out
' the unwanted records, and then export the resulting table as an
' Excel workbook.

'The best solution, however, may be to bypass Excel's import filters


' entirely. You can easily write an import routine in VBA, and allow
' it to process the import file. For instance, consider the following
' macro:

Sub Import()
Sub Import()
Dim sFile As String
Dim sUnwanted As String
Dim sDelim As String
Dim iRow As Integer
Dim iCol As Integer
Dim bBadRecord As Boolean
Dim iTemp As Integer

sFile = "d:\data.txt"
sUnwanted = "bad text"
sDelim = ","

Open sFile For Input As #1

iRow = 1
While Not EOF(1) 'Scan file line by line
iCol = 1
Line Input #1, sBuffer

' Check to see if should ignore record


bBadRecord = Instr(sBuffer, sUnwanted)

If Not bBadRecord Then


iTemp = Instr(sBuffer, sDelim)
While iTemp > 0
With Application.Cells(iRow, iCol)
.NumberFormat = "@" 'Text formatting
.Value = Left(sBuffer, iTemp-1)
End With
iCol = iCol + 1
sBuffer = Mid(sBuffer, iTemp+1, Len(sBuffer))
iTemp = Instr(sBuffer, sDelim)
Wend
If Len(sBuffer) > 0 Then
With Application.Cells(iRow, iCol)
.NumberFormat = "@" 'Text formatting
.Value = sBuffer
End With
End If
iRow = iRow + 1
End If
Wend
Close #1
End Sub
___________________________________________________________________________________
_________________
'This macro opens a data file and reads each record in the file. It
' checks the record to make sure it is OK to import, and then pulls
' the record apart, based on a delimiter, and stuffs the information
' into the current worksheet. You can change the name of the data file
' (the sFile variable), the text that indicates a bad record
' (sUnwanted variable) and the delimiter (sDelim variable).

'As an example, let's assume that you have a data file named
' Customers.txt. This file contains all your customer records, but you
' don't want to import the records for customers with addresses inside
' the United States. Further, the records in the data file use a tab
' character between each field. In this case, you would only need to
' make the following changes to the variables at the beginning of the
' macro:
' sFile = "d:\Customers.txt"
' sUnwanted = "United States"
' sDelim = Chr(9)

'Once you run the macro, the current worksheet contains just the
' desired data.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
{ ( � [ � | � ] � ) } { ( � [ � | � ] � ) { ( � [ � | � ] � ) { ( � [ �
| � ] � )
{ ( � [ � | � ] � ) { ( � [ � | � ] � ) { ( � [ � | � ] � )
{ ( � [
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

��) } { (�� ��) } { (�� ��) } { (�� ��) } { (��


��) } { (�� ��) } { (��
��} �} �>} ])� =)+(= �([ {<� {� {�� ��} �} �>} ])� =)+(= �([ {<� {� {��
��} �} �>} ])� =)+(= �([ {<� {� {��
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^
(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!(&!
(&!(&!(&!(&!(&!
)
^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#)^#
)^#
_-^-_)(-_^_-)(_-^-_-)(--^--)(--^--)(--^--)(-^-)(-^-)(-^-)(-^-)(-^-)(-^-)(-^-)(-^-)
(-^-)(-^-)(-^
_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)
(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_�}{�_-)(-_

H="Running a Macro whenX/;-> _AS_ a Workbook is Closed"

'by Allen Wyatt (last updated May 7, 2011)


'

'You can cause Excel to run a macro automatically whenever a


' particular workbook is closed. For instance, when the workbook is
' closed you might want to run a macro that asks the users if they
' want to perform some task, such as saving the day's data to another
' file.

'In order to run a macro automatically when a workbook is closed, all


' you need to do is name the macro Auto_Close(). Thus, the following
' example macro is run automatically whenever the workbook containing
' it is closed:

Sub Auto_Close()
Dim intStatusState As Integer

intStatusState = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Application.StatusBar = "Examining transactions."
DetermineTransactions
Application.StatusBar = "Posting transactions."
PostTransactions
Application.StatusBar = False
Application.DisplayStatusBar = intStatusState
End Sub
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+^(_+
^(_+^(_+^(_+^
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Copying Comments to Cells"

'by Allen Wyatt (last updated December 14, 2010)


'

'Hector has a large worksheet containing approximately 600 rows and 70


' columns. Spread throughout these 43,000 cells are about 200 cells
' with comments. Hector wants to extract the comments and place them
' into cells to the right of the main body of the data table. If a
' comment, for instance, is attached to cell C43, then he'd like the
' text from that comment to end up in cell CC43 and the original
' comment to be deleted.

'You might think that you could use Paste Special to perform the task,
' but that doesn't work. If you copy the original cells and then use
' Edit | Paste Special | Comments, then only the comments are pasted
' to the target cells. They are still comments, and not text in cells,
' which goes against Hector's goal.

'The only way to handle this type of extraction is to use a macro. The
' following, when run on a selection of cells, will extract the
' comments, move the comment text, and then delete the original
' comment.

Sub CommentsToCells()
Dim rCell As Excel.Range
Dim rData As Excel.Range
Dim sComment As String

' Horizontal displacement


Const iColOffset As Integer = 78

' extract comments from selected range


If TypeName(Selection) = "Range" Then
Set rData = Intersect(Selection, ActiveSheet.UsedRange)
For Each rCell In rData.Cells
On Error Resume Next
sComment = rCell.Comment.Text
If Len(sComment) > 0 Then
rCell.Offset(, iColOffset).Value = sComment
rCell.Comment.Delete
End If
sComment = ""
On Error GoTo 0
Next
End If
End Sub
___________________________________________________________________________________
_________________
'The macro uses the iColOffset constant to specify how many cells to
' the right a comment's text should be moved. In this case, the offset
' (78) is equal to three "alphabets" (26 * 3), so the text of a
' comment originally in column C will end up in column CC.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
___________________________________________________________________________________
_________________
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!

H="Using Message Boxes"

'by Allen Wyatt (last updated July 2, 2009)


'

'When you create macros in VBA, you can easily incorporate the use of
' message boxes. These are typically used to convey information to the
' user and to get some rudimentary input. You include message boxes by
' using the MsgBox command. The following portion of a macro creates a
' very simple message box:
'MsgBox "The Macro is Done"

'You can also add symbols to your message boxes by including one a
' symbol type code as part of your MsgBox invocation. These symbols
' are used extensively in many Windows dialog boxes. The following
' four types of symbols can be used:Type Symbol
'16 Stop sign
'32 Question mark in a circle
'48 Exclamation point in a circle
'64 Information symbol (lowercase i in a circle)

'As an example, let's suppose you wanted to include the exclamation


' point symbol. This is typically included in dialog boxes as a notice
' of when something important has happened or is about to happen. To
' include this symbol in your message box, you would include the
' following macro code:
'MsgBox "Can't run this macro on this text", 48

'So far the MsgBox command has been used as a statement, but you can
' also use it as a function. If you do so, you can use it to get
' simple input from the user. To make the MsgBox function more useful,
' Excel allows you to display more clickable buttons in the dialog box
' besides the OK button. This is done by adjusting the type code,
' which was used for the symbols displayed in the message box. The
' following are the different button combinations you can display in
' your message box:Type Button Types
'1 OK, Cancel
'2 Abort, Retry, Ignore
'3 Yes, No, Cancel
'4 Yes, No
'5 Retry, Cancel

'To use the buttons, you simply add the value of the button type to
' the value you want used for the symbol. In the previous example, you
' used the code of 48 to display the exclamation point symbol. If you
' wanted to also include the Abort, Retry, Ignore buttons, you simply
' change the code to 50, which is 48 (the symbol code) plus 2 (the
' button code).

'When using buttons in this way, the MsgBox function returns a value
' indicating which button the user chose. The buttons return, from
' left to right, -1, 0, and 1. Thus, if you use a button code of 3,
' then -1 would mean the user chose Yes, 0 would mean No, and 1 would
' mean Cancel.

)
*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*
_)*_)*_)*_)*_)*
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^

!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Developing Reciprocal Conversion Formulas"

'by Allen Wyatt (last updated November 27, 2010)


'

'Jeremy posed a problem that is based on two cells, A1 and C1. These
' cells are designed to contain inches and millimeters, respectively.
' Jeremy wants a way that someone could enter a value in A1 and it
' would be converted to millimeters in C1. Conversely, they could
' enter a value in C1 and it would be converted to inches in A1.

'Doing the conversion, of course, isn't the real issue. The problem is
' that if someone enters a value in A1, that value will overwrite any
' formula that may be in that cell, and mean that any subsequent value
' entered in cell C1 would not give the required conversion in the
' previously overwritten A1.

'There are a couple of different ways that this could be approached.


' If you don't mind expanding your worksheet design to include two
' more cells, those cells could be used strictly for input and cells
' A1 and C1 could be used strictly for output. One of the input cells
' could contain the value to be converted and the other could contain
' the measurement unit of the input value (in or mm, for instance).

'Of course, if you want to really limit yourself to two cells, then
' you will need to resort to using macros to do the actual conversion.
' You can use a worksheet event that is triggered every time a cell
' value is changed, and the event handler could check to see if the
' cell being changes is either A1 or C1. The following macro gives an
' example of how this could work:

Private Sub Worksheet_Change(ByVal Target As Range)


Application.EnableEvents = False
With ActiveSheet
If Target = .[A1] Then
.[C1].Value = .[A1].Value * 25.4
ElseIf Target = .[C1] Then
.[A1].Value = .[C1].Value / 25.4
End If
End With
Application.EnableEvents = True
End Sub
___________________________________________________________________________________
_________________
'Note that you don't have to have any formulas in cells A1 or C1; the
' formulas are in the macro itself. If there is a change in cell A1
' (inches are entered by the user), then the value in cell C1 is
' changed by the macro. Likewise, if there is a change in cell C1
' (millimeters are entered by the user), then the value in cell A1 is
' changed by the macro. A change in any other cell besides A1 or C1 is
' ignored by the macro.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Putting an X in a Clicked Cell"

'by Allen Wyatt (last updated May 6, 2011)


'

'Wendy has a worksheet that has quite a bit of data in it, with the
' main data in the range C3:P312. She would like to have a macro that,
' if she clicks a cell in this data range, would put an "x" into the
' cell.

'There is no event that Excel can recognize as a "click" on a cell.


' Perhaps the closest event is the SelectionChange event, which is
' triggered every time the cell selection changes. The event handler
' could then check to make sure that the cell selection is within the
' C3:P312 range, and then place an "x" in the cell if it is. The
' following event handler will do that:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rInt As Range
Dim rCell As Range

Set rInt = Intersect(Target, Range("C3:P312"))


If Not rInt Is Nothing Then
For Each rCell In rInt
rCell.Value = "x"
Next
End If
Set rInt = Nothing
Set rCell = Nothing
End Sub
___________________________________________________________________________________
_________________

'There is a problem with this approach, however: Not only will the
' SelectionChange event trigger when you click on a different cell, it
' also triggers if you use the keyboard to move from one cell to
' another in the worksheet. This means that if you use the keyboard to
' move about the worksheet you will leave a tail of "x" characters in
' each cell you transit.

'One way around this is to change the event that triggers the check
' and change of the cells. While Excel has no "click" event, there is
' a "double click" event. This means that you can change the cell on
' which you double click, as shown here:
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim rInt As Range
Dim rCell As Range
Set rInt = Intersect(Target, Range("C3:P312"))
If Not rInt Is Nothing Then
For Each rCell In rInt
rCell.Value = "x"
Next
End If
Set rInt = Nothing
Set rCell = Nothing
Cancel = True
End Sub
___________________________________________________________________________________
_________________

_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="DOS From Macros"

by Allen Wyatt (last updated January 29, 2011)

Macros are a wonderful way to expand the functionality of a program such as Excel.
You may, however, want to expand that functionality even more by executing a DOS
batch file from your macro. Excel allows you to do this by using the Shell command.
The general syntax for the command is as follows:
dRetVal = Shell("myfile.bat", mode)

Within the quote marks you can place the full path name and file name of the file
you want to execute. On some systems you may experience problems if you use a path
name with the file specification. (This seems to crop its ugly head if you have
complex path names or if the path name includes spaces.) If you have this problem,
then simply use the ChDir command just prior to Shell in order to change the
directory used by Excel. You can then execute Shell using just a file name.

The mode indicator simply tells Excel how you want the window opened for the file
to appear. The mode indicator can be any of the following:Value Variable Nam
Meaning
0 vbHide Window is hidden and has focus.
1 vbNormalFocus Window is the normal size and has focus.
2 vbMinimizedFocus Window is minimized and has focus.
3 vbMaximizedFocus Window is maximized and has focus.
4 vbNormalNoFocus Window is normal size, but doesn't have focus.
6 vbMinimizedNoFocus Window is minimized, but doesn't have
focus.
The Shell command returns a value that indicates the program ID of the file you
executed, or else a zero. If a zero is returned, then there was an error executing
the file.

You should remember that when you use Shell, the target file is executed right
away, and it is executed independently of Excel. This means that the next macro
command, in your Excel macro, is immediately executed without waiting for the Shell
target file to finish. Unfortunately, there is no way around this behavior.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Conditionally Playing an Audio File"

'by Allen Wyatt (last updated May 5, 2011)


'

'Tassos would like to have Excel play an audio file when the value in
' a certain cell exceeds a threshold. For instance, when the value in
' a cell exceeds 999 he would like a particular sound file to be
' played.

'There is no built-in way to do this in Excel (although it would be an


' interesting addition to Excel's conditional formatting features).
' You can, however, play a sound file by using a macro to do a call to
' the Windows API.
'You need to start by placing some code in the Sheet object for the
' workbook. (Right-click the tab for the worksheet and choose View
' Code from the Context menu.) Declare the function "playsound" using
' the following code:

Private Declare Function PlaySound Lib "winmm.dll" _


Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0


Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

'Next you can create a short little macro that will actually play the
' sound file. Assuming that the sound file is in the same directory as
' the workbook, the following code will work. (You should modify the
' code so that it contains the proper filename and location.)

Sub PlayWAV()
WAVFile = ThisWorkbook.Path & "\MyAudioFile.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
___________________________________________________________________________________
_________________

'Finally, establish the criteria when the file is to be played. In


' this case you want the sound file to play whenever the value in the
' target cell exceeds the threshold value of 999. The following will
' check for that condition in cell C5 and, if warranted, play the
' sound file:

Private Sub Worksheet_Change(ByVal Target As Range)


Threshold = 999
If Range("C5").Value > Threshold Then PlayWAV
End Sub
___________________________________________________________________________________
_________________

'Now, whenever the value in Cell C5 changes and exceeds 999, the audio
' file will play one time. If the values is changed to less than 999,
' nothing plays. If the value changes to another value that exceeds
' 999, the sound file will play again.

'For additional ideas on playing audio files, check out these sites:
'http://www.j-walk.com/ss/excel/tips/tip87.htm
'http://www.cpearson.com/excel/PlaySound.aspx

'You should note, as well, that you can get Excel to play a system
' sound by using data validation. Simply set up the validation
' criteria (described in other issues of ExcelTips) and then, on the
' Error tab, specify whether you want Excel to stop, warn, or inform
' the user. When a value is entered in the cell that does not fit the
' criteria, a dialog box is displayed and the system sound is heard.
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Code:HyperlinkFileList() "

instructions for use

Option Compare Text


Option Explicit

Function Excludes(Ext As String) As Boolean


'Function purpose: To exclude listed file extensions from hyperlink listing

Dim X, NumPos As Long

'Enter/adjust file extensions to EXCLUDE from listing here:


X = Array("exe", "bat", "dll", "zip")

On Error Resume Next


NumPos = Application.WorksheetFunction.Match(Ext, X, 0)
If NumPos > 0 Then Excludes = True
On Error Goto 0

End Function
Sub HyperlinkFileList()
'Macro purpose: To create a hyperlinked list of all files in a user
'specified directory, including file size and date last modified
'NOTE: The 'TextToDisplay' property (of the Hyperlink object) was added
'in Excel 2000. This code tests the Excel version and does not use the
'Texttodisplay property if using XL 97.

Dim fso As Object, _


ShellApp As Object, _
File As Object, _
SubFolder As Object, _
Directory As String, _
Problem As Boolean, _
ExcelVer As Integer

'Turn off screen flashing


Application.ScreenUpdating = False

'Create objects to get a listing of all files in the directory


Set fso = CreateObject("Scripting.FileSystemObject")

'Prompt user to select a directory


Do
Problem = False
Set ShellApp = CreateObject("Shell.Application"). _
Browseforfolder(0, "Please choose a folder", 0, "c:\\")

On Error Resume Next


'Evaluate if directory is valid
Directory = ShellApp.self.path
Set SubFolder = fso.GetFolder(Directory).Files
If Err.Number <> 0 Then
If MsgBox("You did not choose a valid directory!" & vbCrLf & _
"Would you like to try again?", vbYesNoCancel, _
"Directory Required") <> vbYes Then Exit Sub
Problem = True
End If
On Error Goto 0
Loop Until Problem = False

'Set up the headers on the worksheet


With ActiveSheet
With .Range("A1")
.Value = "Listing of all files in:"
.ColumnWidth = 40
'If Excel 2000 or greater, add hyperlink with file name
'displayed. If earlier, add hyperlink with full path displayed
If Val(Application.Version) > 8 Then 'Using XL2000+
.Parent.Hyperlinks.Add _
Anchor:=.Offset(0, 1), _
Address:=Directory, _
TextToDisplay:=Directory
Else 'Using XL97
.Parent.Hyperlinks.Add _
Anchor:=.Offset(0, 1), _
Address:=Directory
End If
End With
With .Range("A2")
.Value = "File Name"
.Interior.ColorIndex = 15
With .Offset(0, 1)
.ColumnWidth = 15
.Value = "Date Modified"
.Interior.ColorIndex = 15
.HorizontalAlignment = xlCenter
End With
With .Offset(0, 2)
.ColumnWidth = 15
.Value = "File Size (Kb)"
.Interior.ColorIndex = 15
.HorizontalAlignment = xlCenter
End With
End With
End With

'Adds each file, details and hyperlinks to the list


For Each File In SubFolder
If Not Excludes(Right(File.path, 3)) = True Then
With ActiveSheet
'If Excel 2000 or greater, add hyperlink with file name
'displayed. If earlier, add hyperlink with full path displayed
If Val(Application.Version) > 8 Then 'Using XL2000+
.Hyperlinks.Add _
Anchor:=ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0), _
Address:=File.path, _
TextToDisplay:=File.Name
Else 'Using XL97
.Hyperlinks.Add _
Anchor:=ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0), _
Address:=File.path
End If
'Add date last modified, and size in KB
With .Range("A65536").End(xlUp)
.Offset(0, 1) = File.datelastModified
With .Offset(0, 2)
.Value = WorksheetFunction.Round(File.Size / 1024, 1)
.NumberFormat = "#,##0.0"
End With
End With
End With
End If
Next

End Sub
___________________________________________________________________________________
_________________

'How to use:
'Copy above code.
'In Excel press Alt + F11 to enter the VBE.
'Press Ctrl + R to show the Project Explorer.
'Right-click desired file on left (in bold).
'Choose Insert -> Module.
'Paste code into the right pane.
'Scroll to find the "Function Excludes" function
'Review the line starting "X=Array". Remove any extension you DO want
' to see in the list, and add any extension you DON'T want to see in
' the list. (For example if you don't want to see Word documents, add:
' ,"doc" after the "zip" portion of the line)
'Press Alt + Q to close the VBE.
'Save workbook before any other changes.
'
'Test the code:
'Select (or create) a blank worksheet
'From Excel, run macro 'HyperlinkFileList' by pressing Alt+F8.
'Choose a directory from the explorer window that pops up, and click
' Okay
'If you have not selected a valid directory ('My computer', 'Network
' Neighborhood', etc...) you will be asked if you would like to try
' again
'Your list will be created
'

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Removing Conditional Formats, but Not the Effects"

'by Allen Wyatt (last updated February 21, 2011)


'
'Charlie wondered if there is a way to "make permanent" the effects of
' conditional formatting at any given time. For instance, if a
' conditional format specifies that a particular cell be bold red
' type, then Charlie wanted a way to remove the conditional format and
' make the cell bold and red.
'There is no intrinsic way to do this in Excel; none of the Paste
' Special options will do the task, as desired. You can, however, use
' a macro to accomplish the task:

Option Explicit
Sub PasteFC()
Application.ScreenUpdating = False
Dim rWhole As Range
Dim rCell As Range
Dim ndx As Integer
Dim FCFont As Font
Dim FCBorder As Border
Dim FCInt As Interior
Dim x As Integer
Dim iBorders(3) As Integer

iBorders(0) = xlLeft
iBorders(1) = xlRight
iBorders(2) = xlTop
iBorders(3) = xlBottom

Set rWhole = Selection

For Each rCell In rWhole


rCell.Select
ndx = ActiveCondition(rCell)
If ndx <> 0 Then
'Change the Font info
Set FCFont = rCell.FormatConditions(ndx).Font
With rCell.Font
.Bold = NewFC(.Bold, FCFont.Bold)
.Italic = NewFC(.Italic, FCFont.Italic)
.Underline = NewFC(.Underline, FCFont.Underline)
.Strikethrough = NewFC(.Strikethrough, _
FCFont.Strikethrough)
.ColorIndex = NewFC(.ColorIndex, FCFont.ColorIndex)
End With
'Change the Border Info for each of the 4 types
For x = 0 To 3
Set FCBorder = rCell.FormatConditions(ndx).Borders(iBorders(x))
With rCell.Borders(iBorders(x))
.LineStyle = NewFC(.LineStyle, FCBorder.LineStyle)
.Weight = NewFC(.Weight, FCBorder.Weight)
.ColorIndex = NewFC(.ColorIndex, FCBorder.ColorIndex)
End With
Next x
'Change the interior info
Set FCInt = rCell.FormatConditions(ndx).Interior
With rCell.Interior
.ColorIndex = NewFC(.ColorIndex, FCInt.ColorIndex)
.Pattern = NewFC(.Pattern, FCInt.Pattern)
End With
'Delete FC
rCell.FormatConditions.Delete
End If
Next
rWhole.Select
Application.ScreenUpdating = True
MsgBox ("The Formatting based on the Conditions" & vbCrLf & _
"in the range " & rWhole.Address & vbCrLf & _
"has been made standard for those cells" & vbCrLf & _
"and the Conditional Formatting has been removed")
End Sub
___________________________________________________________________________________
_________________
Function NewFC(vCurrent As Variant, vNew As Variant)
If IsNull(vNew) Then
NewFC = vCurrent
Else
NewFC = vNew
End If
End Function
Function ActiveCondition(rng As Range) As Integer
'Chip Pearson http://www.cpearson.com/excel/CFColors.htm
Dim ndx As Long
Dim FC As FormatCondition

If rng.FormatConditions.Count = 0 Then
ActiveCondition = 0
Else
For ndx = 1 To rng.FormatConditions.Count
Set FC = rng.FormatConditions(ndx)
Select Case FC.Type
Case xlCellValue
Select Case FC.Operator
Case xlBetween
If CDbl(rng.Value) >= CDbl(FC.Formula1) And _
CDbl(rng.Value) <= CDbl(FC.Formula2) Then
ActiveCondition = ndx
Exit Function
End If
Case xlGreater
If CDbl(rng.Value) > CDbl(FC.Formula1) Then
ActiveCondition = ndx
Exit Function
End If
Case xlEqual
If CDbl(rng.Value) = CDbl(FC.Formula1) Then
ActiveCondition = ndx
Exit Function
End If
Case xlGreaterEqual
If CDbl(rng.Value) >= CDbl(FC.Formula1) Then
ActiveCondition = ndx
Exit Function
End If
Case xlLess
If CDbl(rng.Value) < CDbl(FC.Formula1) Then
ActiveCondition = ndx
Exit Function
End If
Case xlLessEqual
If CDbl(rng.Value) <= CDbl(FC.Formula1) Then
ActiveCondition = ndx
Exit Function
End If
Case xlNotEqual
If CDbl(rng.Value) <> CDbl(FC.Formula1) Then
ActiveCondition = ndx
Exit Function
End If
Case xlNotBetween
If CDbl(rng.Value) <= CDbl(FC.Formula1) Or _
CDbl(rng.Value) >= CDbl(FC.Formula2) Then
ActiveCondition = ndx
Exit Function
End If
Case Else
Debug.Print "UNKNOWN OPERATOR"
End Select
Case xlExpression
If Application.Evaluate(FC.Formula1) Then
ActiveCondition = ndx
Exit Function
End If
Case Else
Debug.Print "UNKNOWN TYPE"
End Select
Next ndx
End If
ActiveCondition = 0
End Function
'There are three procedures in this solution. The last procedure,
' ActiveCondition, is designed to return a number indicating which of
' the conditions in a conditional format is currently in effect. This
' routine was found at Chip Pearson's site, as indicated in the first
' comment of the function. (No sense in re-inventing the wheel. :>))
'The center function, NewFC, is simply used to determine which of two
' values is valid. The procedure you actually run, however, is
' PasteFC. Simply select the cells you want to convert to explicit
' formatting, then run the procedure. It checks each cell you selected
' for which formatting condition is active, determines the formatting
' of that condition, and then applies it to the cell. Finally, the
' conditional formatting for the cell is removed.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Setting a Length Limit on Cells"

'by Allen Wyatt (last updated February 26, 2011)

'
'Craig is developing a worksheet and wants to know if there is a way
' to specify the maximum number of characters that can be entered in
' any given cell. He doesn't want to use Data Validation to impose the
' limitation.
'There is no way to do this directly in Excel without (as Craig
' mentions) using Data Validation. There are a few things you can try
' to achieve the desired effect, however. First, you can using a
' formula to check the length of any cell, and then display an error
' message, if desired. For instance, if the cells you want to check
' are in column C, you could use a formula such as the following:
'=IF((LEN(C1)>15),"Cell is Too Long","")
'Place the formula in the cell to the right of the cell being checked
' (such as in cell D1), and then copy it down as many cells as
' necessary. When an entry is made in C1, and if it is more than 15
' characters, then the message is displayed.
'If such a direct approach is undesirable, then you'll need to use
' macros to do the checking. The following is a simple example that is
' triggered whenever something is changed in the worksheet. Each cell
' in the worksheet is then checked to make sure it is not longer than
' 15 characters. If such a cell is discovered, then a message box is
' displayed and the cell is cleared.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


For Each cell In UsedRange
If Len(cell.Value) > 15 Then
MsgBox " Can't enter more than 15 characters"
cell.Value = ""
End If
Next
End Sub
___________________________________________________________________________________
_________________
'A more robust approach is to check in the event handler to see if the
' change was made somewhere within a range of cells that need to be
' length-limited.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)


Dim rng As Range
Dim rCell As Range
Dim iChars As Integer
On Error GoTo ErrHandler

'Change these as desired


iChars = 15
Set rng = Me.Range("A1:A10")

If Not Intersect(Target, rng) Is Nothing Then


Application.EnableEvents = False
For Each rCell In Intersect(Target, rng)
If Len(rCell.Value) > iChars Then
rCell.Value = Left(rCell.Value, iChars)
MsgBox rCell.Address & " has more than" _
& iChars & " characters." & vbCrLf _
& "It has been truncated."
End If
Next
End If

ExitHandler:
Application.EnableEvents = True
Set rCell = Nothing
Set rng = Nothing
Exit Sub

ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
___________________________________________________________________________________
_________________
'To use this macro, you simply need to change the value assigned to
' iChars (represents the maximum length allowed) and the range
' assigned to rng (currently set to A1:A10). Because the macro checks
' only for changes within the specified range, it is much faster with
' larger worksheets than the macro that checks all the cells used.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Finding Unused Names"

'by Allen Wyatt (last updated November 19, 2011)

'
'Richard has a workbook that he's been using for a while, and it has
' quite a few names in it (named ranges, named formulas, etc.). He
' wonders if there is an easy way to find names that are not used at
' all, as he'd like to get rid of those names.
'There is no built-in way to get rid of these unused names. You can,
' however, create a macro that will do the trick for you. This is most
' easily done by using the Find method to figure out which names have
' references that can be "found." If the reference cannot be found,
' then the name is not in use.

Sub RidOfNames()
Dim myName As Name
Dim fdMsg As String

On Error Resume Next


fdMsg = ""
For Each myName In Names
If Cells.Find(What:=myName.Name, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate = False Then
fdMsg = fdMsg & myName.Name & vbCr
ActiveWorkbook.Names(myName.Name).Delete
End If
Next myName
If fdMsg = "" Then
MsgBox "No unused names found in the workbook"
Else
MsgBox "Names Deleted:" & vbCr & fdMsg
End If
End Sub
___________________________________________________________________________________
_________________
'The macro steps through all the elements of the Names collection and
' does a search for each name. If the name cannot be found, then the
' name is deleted. When the macro is completed, it displays a message
' box that lists the names that were removed from the workbook.
'If you would rather not create your own macro, you can opt to use a
' free add-in by Jan Karel Pieterse. The add-in, called Name Manager,
' allows you to (guess what?) manage names better than you can do with
' native Excel. One of the functions it provides is the ability to get
' rid of names that are no longer needed. You can find the add-in here:
'http://www.jkp-ads.com/OfficeMarketPlaceNM-EN.asp

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Deleting Everything Up to a Character Sequence"


'by Allen Wyatt (last updated December 26, 2009)

'
'Steven has a worksheet that has lots of text in it. In the cells in
' column A he wants to delete everything that may occur before a given
' sequence of characters, such as everything before =XX=. There may be
' multiple instances of these characters in each cell, but Steven only
' wants to delete everything before the first occurrence.
'One way to do this is to use a formula. For instance, the following
' formula will evaluate whatever is in cell A1 and simply return
' everything up to the =XX= characters. If the characters are not
' found in the cell, then the entire cell is returned:
'=RIGHT(A1,IF(ISERROR(FIND("=XX=",A1,1)),
'LEN(A1),LEN(A1)-FIND("=XX=",A1,1)+1))
'If you want, instead, to not return the first occurrence of =XX=, all
' you need to do is change the +1 near the end of the formula to -3.
'If you prefer a macro-based solution you could use a routine like the
' following. It examines all the cells that are currently selected and
' then deletes everything before the =XX= sequence.

Sub DeleteToSequence()
Dim rCell As Range
Dim sSeq As String
Dim x As Long

sSeq = "=XX="
For Each rCell In Selection
x = InStr(rCell.Value, sSeq)
If x > 0 Then
rCell.Value = Mid(rCell, x)
End If
Next

Set rCell = Nothing


End Sub
___________________________________________________________________________________
_________________
'You should be aware that this macro can cause some errors,
' particularly when what you are searching for begins with an equal
' sign (as in =XX=). When a string beginning with an equal sign is
' stuffed back into the cell, you'll get a #NAME? error because Excel
' tries to parse the cell as if it contains a formula.
'If you want to delete everything up through the character sequence,
' use this line in the middle of the routine:
'rCell.Value = Mid(rCell, x + Len(sSeq))

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="This can be done with a formula, but it quickly becomes unwieldy. For instance,
the following formula can be used to put dashes between the letters of whatever you
type into cell A1:
=CHOOSE(LEN(A1),A1,LEFT(A1,1) & "-" & RIGHT(A1,1),
LEFT(A1,1) & "-" & MID(A1,2,1) & "-" & RIGHT(A1,1),
LEFT(A1,1) & "-" & MID(A1,2,1) & "-" & MID(A1,3,1) & "-"
& RIGHT(A1,1),LEFT(A1,1) & "-" & MID(A1,2,1) & "-"
& MID(A1,3,1) & "-" & MID(A1,4,1) & "-" & RIGHT(A1,1),
LEFT(A1,1) & "-" & MID(A1,2,1) & "-" & MID(A1,3,1)
& "-" & MID(A1,4,1) & "-" & MID(A1,5,1) & "-" & RIGHT(A1,1))
This particular example of a formula will only work on text up to six characters in
length. Thus, it would work properly for "house", but not for "household". The
formula could be lengthened but, again, it would quickly become very long.
A better approach is to use a macro to do the conversion. If you want to insert the
dashes right into the cell, you could use a macro such as this:
Sub AddDashes1()
Dim Cell As Range
Dim sTemp As String
Dim C As Integer

For Each Cell In Selection


sTemp = ""
For C = 1 To Len(Cell)
sTemp = sTemp + Mid(Cell, C, 1) + "-"
Next
Cell.Value = Left(sTemp, Len(sTemp) - 1)
Next
End Sub
___________________________________________________________________________________
_________________
This macro is designed to be used on a selected range of cells. Just select the
cells you want to convert, and then run the macro. The dashes are added between
each letter in the cells.
If you prefer to not modify the original cell values, you could create a user-
defined function that would do the job:
Function AddDashes2(Src As String) As String
Dim sTemp As String
Dim C As Integer

Application.Volatile
sTemp = ""
For C = 1 To Len(Src)
sTemp = sTemp + Mid(Src, C, 1) + "-"
Next
AddDashes2 = Left(sTemp, Len(sTemp) - 1)
End Function
To use this function you would use the following in your worksheet:
=AddDashes2(A1)
If you want to make sure that the function is a bit more robust, you could modify
it so that it handles multiple words. In such an instance you would not want it to
treat a space as a "dashable letter." For example, you would want the routine to
add dashes to "one two" so it came out as "o-n-e t-w-o" instead of "o-n-e- -t-w-o".
The following variation on the function will do the trick:
Function AddDashes3(Src As String) As String
Dim sTemp As String
Dim C As Integer

Application.Volatile
sTemp = ""
For C = 1 To Len(Src)
sTemp = sTemp + Mid(Src, C, 1)
If Mid(Src, C, 1) <> " " And
Mid(Src, C + 1, 1) <> " " And
C < Len(Src) Then
sTemp = sTemp + "-"
End If
Next
AddDashes3 = sTemp
End Function

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Getting a List of Installed Fonts"

Your VBA procedure might need to present the user with a list of fonts to choose
from. Or, you may need to determine if a particular font is installed. The simplest
way to access the installed font list is to get the fonts from the Font control on
the Formatting toolbar. The Font control contains a dropdown list of installed
fonts, and you can write VBA code to retrieve that list from the control.
Displaying font names

The procedure listed below displays a list of installed fonts in Column A of the
active worksheet. It uses the FindControl method to locate the Font control on the
Formatting toolbar. If this control is not found (i.e., it was removed by the user)
a temporary CommandBar is created and the Font control is added to it.
Sub ShowInstalledFonts()
Set FontList = Application.CommandBars("Formatting").FindControl(ID:=1728)

' If Font control is missing, create a temp CommandBar


If FontList Is Nothing Then
Set TempBar = Application.CommandBars.Add
Set FontList = TempBar.Controls.Add(ID:=1728)
End If

' Put the fonts into column A


Range("A:A").ClearContents
For i = 0 To FontList.ListCount - 1
Cells(i + 1, 1) = FontList.List(i + 1)
Next i

' Delete temp CommandBar if it exists


On Error Resume Next
TempBar.Delete
End Sub
___________________________________________________________________________________
_________________
Is a font installed?

The function below uses the same technique as the ShowInstalledFonts procedure. it
returns True if a specified font is installed.
Function FontIsInstalled(sFont) As Boolean
' Returns True if sFont is installed
FontIsInstalled = False
Set FontList = Application.CommandBars("Formatting").FindControl(ID:=1728)
' If Font control is missing, create a temp CommandBar
If FontList Is Nothing Then
Set TempBar = Application.CommandBars.Add
Set FontList = TempBar.Controls.Add(ID:=1728)
End If

For i = 0 To FontList.ListCount - 1
If FontList.List(i + 1) = sFont Then
FontIsInstalled = True
On Error Resume Next
TempBar.Delete
Exit Function
End If
Next i

' Delete temp CommandBar if it exists


On Error Resume Next
TempBar.Delete
End Function

The statement below demonstrates how to use this function in a VBA procedure. It
displays True in a message box if the user's system contains the Comic Sans MS
font.
MsgBox FontIsInstalled("Comic Sans MS")

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Cell addressing in VBA (#vbacell)"

Since there are several examples on this page, this seems about as good a place as
any to include the following information.

Find the numeric column number equivalent for Column "AB".


MsgBox "Numeric equivalent for AB is " & Range("ab" & "1").Column
Find Column number of the selected cell or the last cell.
Set lastcell = Cells.SpecialCells(xlLastCell)
lRows = lastcell.Row
lCols = lastcell.Column

Row = activecell.row
Col = activecell.column
Find Column letters of the selected cell
Columns run A through IV (1-256), length is 1 for < 27, or 2 above 26.
= Left(ActiveCell.Address(0, 0), (ActiveCell.Column < 27) + 2)
Even simpler is one from Dana DeLouis, 2001-03-04 in programming
= Split(ActiveCell.Address, "$")(1) 'For Column Letter
= Split(ActiveCell.Address, "$")(2) 'For Row Number
Finding the Relative Address of a cell.
Assumes you have A1 addressing: Tools --> Options --> General --> with R1C1 off

Place address of cell into itself as a text entry -- see MarkCells example above.
Selection.Item(iX) = "'" & Selection.Item(iX).AddressLocal(0, 0)
Followup example:
Sub test10()
'will display CV as equivalent of 100, and 28 for AB
C = 100
MsgBox "Alpha equivalent for Col " & C & " is " & _
Left(cells(1, C).AddressLocal(0, 0), _
Len(cells(1, C).AddressLocal(0, 0)) - 1)
MsgBox "Numeric equivalent for AB is " & Range("ab" & "1").Column
End Sub
___________________________________________________________________________________
_________________
Worksheet Example of converting column number to a Letter
Will convert numbers 1 to 256 to Excel column letters A to IV.
256 IV =LEFT(ADDRESS(1,A1,4),LEN(ADDRESS(1,A1,4))-1)
1 A =LEFT(ADDRESS(1,A2,4),LEN(ADDRESS(1,A2,4))-1)
2 B =LEFT(ADDRESS(1,A3,4),LEN(ADDRESS(1,A3,4))-1)
3 C =LEFT(ADDRESS(1,A4,4),LEN(ADDRESS(1,A4,4))-1)

4 D1 =ADDRESS(1,A5,4) **ADDRESS(row,column)**

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Return string after last "/" character (#aftlast)"

=AFTLAST(E22)

Function AFTLAST(cell As Range, findchar As String) As String


Application.Calculation = xlCalculationManual 'in XL97
Dim i as Long
For i = Len(cell) To 1 Step -1
If Mid(cell, i, 1) = findchar Then
AFTLAST = Mid(cell, i + 1, 99)
Exit Function
End If
Next i
AFTLAST = cell ' or aftlast="" depending on what you want
Application.Calculation = xlCalculationAutomatic 'in XL97
End Function
Return string after first "/" character
Remove everything to left of first "/"
=IF(ISERR(FIND("/",E22)),E22,MID(E22,FIND("/",E22,1)+1,99))
or
=IF(ISERR(FIND("/",E22)),"",MID(E22,FIND("/",E22,1)+1,99))
depending on whether you want cell value or nothing when "/" is not present.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Testing Things on This Web Page (#markcells)

A short demonstration of items on this page can be accomplished by installing each


of the macros on this page -- Join(), ReversI(), SepTerm(), MarkCells(), and
MarkSepAreas(). Each of these macros are frequently used in testing.

MarkCells() will destroy previous contents within Selection RANGE. Each cell will
be identified with it's address when MarkCells was invoked. The examples in
Samples below, and in Delete Cells/Rows in Range, based on empty cells utilized
MarkCells. Some similar items of interest are AAA_ZZZ macro will generate AAAA up
to ZZZZ within a selected range(s). Also of interest is a UDF by Myrna Larson that
increments strings See related area below.

Suggested Toolbar menu item [Mark cells with cell address]


Sub MarkCells()
'David McRitchie 1998-08-17 [Mark cells with cell address] Documented
'with Join() in http://www.mvps.org/dmcritchie/excel/join.htm
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'--Dim iX as Long
'--For iX = 1 To Selection.Count '(0,0) below is same as (False, False)
'-- Selection.Item(iX) = "'" & Selection.Item(iX).AddressLocal(0, 0)
'--Next iX
Dim cell As Range
For Each cell In Selection '(0,0) below is same as (False, False)
cell.Value = "'" & cell.AddressLocal(0, 0)
Next cell
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
The following is a little shorter and eliminates a Dim statement in the old code
now commented out.
A single quote inside double quotes is included in both examples. In Excel 97 and
above the For Each version will handle multiple selected areas.
For Each Cell In Selection
Cell.Value = "'" & Cell.AddressLocal(0, 0)
Next Cell
The Worksheet Function equivalent is =ADDRESS(ROW(),COLUMN(),4) but the value
will change when it is moved to match the cell it is in. The use of MarkCells is
to show where the cell was originally after moving things around, not where it
currently resides after moving things around. You can place 'A1 into cell A1 and
fill down to be more like the macro MarkCells, and when you move things around it
will show where it used to be just like you would see if you had used the macro.

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Reverse Cells in Selection end for end (#reversi)"


ReversI() can be used to reverse the order of items in a row, column, or range. It
can be used to reverse itself. Applied to a SINGLE ROW, the macro will flip about
a vertical axis, or a horizontal axis for a column; otherwise, it really isn't a
flip. Obviously you must select the range (i.e. A1:A30) and not the entire row or
column. If you selected an entire row for instance your data would be so far to
the right that it would take you awhile to find it. If you select a range of
columns and rows the item in the upper left will reappear in the lower right
corner. What previously was ordered down will be up, and what ran left to right
will run right to left. You may notice the division by two; if the item count is
not divisible by two the center item will not be switched. Infrequent use does not
justify a shortcut key. See Samples below for an example of usage.
Sub ReversI()
'David McRitchie 1998-07-30 documented in
' http://www.mvps.org/dmcritchie/excel/join.htm
'Reverse (Flip) Item values in Range, Row, or Column [Ctrl+R]
'Counting in multiple rows/cols, item count proceeds down a
'column in range and continues top of next column in range
Dim tcells As Long, mCells As Long, ix As Long, ox As Long
Dim iValue As Variant
tcells = Selection.Count
mCells = tcells / 2
For ix = 1 To mCells
iValue = Selection.Item(ix).Value
ox = tcells + 1 - ix
Selection.Item(ix).Value = Selection.Item(ox).Value
Selection.Item(ox).Value = iValue
Next ix
End Sub
___________________________________________________________________________________
_________________

Rotate Selection Clockwise (#rotatecw)


This Subroutine will Rotate the selection area A1:xnn 90 degrees ClockWise.
Because Rows are copy and pasted and because TRANSPOSE is used in this macro all
formatting, and formulas are preserved. See RotateCW() Sample in the Sample area.

Part 1, Rotate the Rows


Part 2, TRANSPOSE the rotated Rows for selection area -- Full rows

Note: As written the selection area must include cell A1, and the original
selection area is really the entire rows. This is practical as long as there are
not more than 256 rows selected because of the longstanding 256 column limitation
in Excel. This macro was written to normalize a spreadsheet that could best be
views sideways and had rotated cells that became available in XL97. Until
rewritten arrangement or presence of cells not in selection is undefined.
Sub RotateCW()
'Rotate Clockwise: 1) Rotate rows, 2) TRANSPOSE & delete orig
'David McRitchie, 2000-02-07 MISC., documented in
' http://www.mvps.org/dmcritchie/excel/join.htm
'Cell A1 must be in Selection !!!!!
'must formatting and Formulas are preserved
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual 'pre XL97 xlManual
Dim i As Long
Dim nRows As Long
Dim nCols As Long
Dim curRange As Range
Dim abc As String
Set curRange = Selection
nRows = Selection.Rows.Count
nCols = Selection.Columns.Count
If nRows > 256 Then GoTo done
nRows = InputBox("Specify number of rows, suggesting " & nRows, _
"Selection of Number of rows to Rotate", Selection.Rows.Count)
nRows = nRows + 1 'adjustment for inserts
For i = nRows To 2 Step -1
Rows(1).Select
Selection.Cut
Rows(i).Select
Selection.Insert Shift:=xlUp
Next i
'Have flipped the rows, next step is to TRANSPOSE data with copy
abc = "1:" & nRows - 1
Range(abc).Select
i = MsgBox("Flipping of Rows Completed. Do you want to continue " & _
"with a TRANSPOSE using COPY?", vbOKCancel, "Question")
If i <> 1 Then GoTo done
Selection.Copy
Cells(nRows, 1).Select 'TRANSPOSE to
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Range(Cells(1, 1), Cells(nRows - 1, 256)).Delete
done:
Application.Calculation = xlCalculationAutomatic 'pre XL97 xlAutomatic
Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
Separate first word (term) from remainder of cell (#septerm)
SepTerm() separates the first word (term) from remainder of cell. Remainder goes
to next column. SepTerm() can be used as a reversal of Join and is a more
forgiving option than Data --> Text to Columns. SepTerm() Can be used to separate
the street number from the rest of the street name. Can also be used to separate a
term from a definition.

Only a single column need to be selected. The next column will be tested that it
contains a blank. A check will be made that no cells contain data in the adjacent
column to the right, but you can override this. Even after overriding data will
not be split if it will remove content from the adjacent column. See Samples below
for an example of usage. Suggested shortcut key [Ctrl+t]
Sub SepTerm()
'David McRitchie 1998-08-05 [Ctrl+t] documented in
' http://www.mvps.org/dmcritchie/excel/join.htm
'Separate the first term from remainder, as in separating
'street number as first item from street & remainder
'Work on first column, cell to right must appear to be blank
'--Application.ScreenUpdating = False
'On Error Resume Next
iRows = Selection.Rows.Count
Set lastcell = cells.SpecialCells(xlLastCell)
mRow = lastcell.Row
If mRow < iRows Then iRows = mRow 'not best but better than nothing
For ir = 1 To iRows
If Len(Trim(Selection.Item(ir, 1).Offset(0, 1))) <> 0 Then
iAnswer = MsgBox("Found non-blank in adjacent column -- " _
& Selection.Item(ir, 1).Offset(0, 1) & " -- in " & _
Selection.Item(ir, 1).Offset(0, 1).AddressLocal(0, 0) & _
Chr(10) & "Press OK to process those than can be split", _
vbOKCancel)
If iAnswer = vbOK Then GoTo DoAnyWay
GoTo terminated
End If
Next ir
DoAnyWay:
For ir = 1 To iRows
If Len(Trim(Selection.Item(ir, 1).Offset(0, 1))) <> 0 Then GoTo nextrow
checkx = Trim(Selection.Item(ir, 1))
L = Len(Trim(Selection.Item(ir, 1)))
If L < 3 Then GoTo nextrow
For im = 2 To L
If Mid(checkx, im, 1) = " " Then
Selection.Item(ir, 1) = Left(checkx, im - 1)
Selection.Item(ir, 1).Offset(0, 1) = Trim(Mid(checkx, im + 1))
GoTo nextrow
End If
Next im
nextrow:
Next ir
terminated:
'--Application.ScreenUpdating = True
End Sub
___________________________________________________________________________________
_________________
Considerations in working with data from HTML sources
The macro above does not include replacing a non breaking space character (&nbsp;)
typically used in HTML, with a normal space. You can achieve the replacement with
Worksheet
Ctrl+H, Replace: Alt+0160, With: (space)
with macro code.
Selection.Replace What:=CHR(160), Replacement:=CHR(32), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

A worksheet solution for the above. This will leave the original column and the two
new columns wns will be dependent on the original. You can remove the dependency
by using copy and paste special value. That's why I use a macro.
=LEFT(A3,FIND(" ",A3)-1)
=MID(A3,FIND(" ",A3)+1,LEN(A3)-FIND(" ",A3))
or if only interested in the street, to remove the number at the beginning, if
present, before the first space, use. [Rag Dyer 2005-04-23]
=IF(ISERR(--LEFT(A1,FIND(" ",A1))),"",LEFT(A1,FIND(" ",A1)-1)) -- number if
present
=IF(ISERR(--LEFT(A1,FIND(" ",A1))),A1,MID(A1,FIND(" ",A1)+1,100)) -- street
name
or to include considerations for char(160) but not errors (Peo Sjoblom, misc, 2002-
02-17) -- No consideration for errors is all the more reason to use macros.
for street numbers (leftmost word):
=LEFT(TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," "))),SEARCH("
",TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," "))))-1)

for street names (remainder):


=RIGHT(TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160),"
"))),LEN(TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160),
" "))))-SEARCH(" ",TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," ")))))
VBA for Text to Columns Macros on this page were written to reduce or eliminate
the exposure of overwriting that would occur with the following Text to Columns.
Selection.TextToColumns Space:=True, ConsecutiveDelimiter:=True
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Paste Special Comments (#pastecomments)"

Will paste comments from a copied block of cells to another block of cells.
Sub pastespecialcomments()
Selection.PasteSpecial Paste:=xlPasteComments, _
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
___________________________________________________________________________________
_________________

Could use this one along with the formula to comment, and to a agrouped sheet
before splicing

^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
����������������������������������
v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V_
_v__V__v__V__v__V

H="Option Explicit (Module BEEPS in personal)"

'David McRitchie
' http://www.mvps.org/dmcritchie/excel/code/beeps.txt
' http://www.mvps.org/dmcritchie/excel/funstuff.htm

'module: beeps in personal.xls


'Can't be installed on an object module (sheet)
' Declare Function sndPlaySound32 Lib "c:\winnt\system32\winmm.dll" _'
Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
'your own subroutine can be called from a worksheet event macro

'Related material on sound can be found at John Walkenbach's


' Tip 59 Playing Sound From Excel
' http://www.j-walk.com/ss/excel/tips/tip59.htm

'You can record your own voice for a wave (.wav) file
' My test "Value in A1 is 100" for 2.5 seconds was 64KB
'From the window help file "Sound Recorder" use Click here button
' actually invokes sndrec32.exe
' 1) Record with round button at far right, turns RED when recording
' 2) Stop Recording with black square, just like on a VCR
' 3) Play with the PLAY button, or double click on the speaker
' 4) File, Save As, (save in appropriate file)
' Exit in normal fashion [x]

' Example of an Event Macro -- you will need to make playvalue100 in


' a regular module
' Option Explicit
' Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' If Target.Address(0, 0) = "A1" And Target.Value = 100 Then
' playvalue100
' End If
' End Sub
___________________________________________________________________________________
_________________
___________________________________________________________________________________
_________________
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
Sub Double_beep()
Call sndPlaySound32("c:\i386\ringout.wav", 0)
End Sub
___________________________________________________________________________________
_________________
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V_
_v__V__v__V__v__V
Sub tflush_wav()
' Call sndPlaySound32("c:\winnt\system\t-flush.wav", 0)
Call sndPlaySound32("t-flush.wav", 0)
End Sub
___________________________________________________________________________________
_________________
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V_
_v__V__v__V__v__V
Sub glass_wav()
Call sndPlaySound32("c:\winnt\media\microsoft office 2000\Glass.wav", 0)
End Sub
___________________________________________________________________________________
_________________
����������������������������������
v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V_
_v__V__v__V__v__V
Sub drumroll_wav()
Call sndPlaySound32("default", 0)
' Call sndPlaySound32("c:\winnt\media\microsoft office 2000\drumroll.wav", 0)
End Sub
___________________________________________________________________________________
_________________
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
Sub Whoosh_wav()
Call sndPlaySound32("c:\winnt\media\microsoft office 2000\whoosh.wav", 0)
End Sub
___________________________________________________________________________________
_________________
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
Sub RingIn_wav()
Call sndPlaySound32("c:\program files\netmeetingNT\ringin.wav", 0)
End Sub
___________________________________________________________________________________
_________________
Public Sub MakeWavFile()
' preparation:
' dir c:*.wav /s /n > c:\temp\t.txt
' dir h:*.wav /s /n >> c:\temp\t.txt
Dim strPath As String
Dim strFile As String
Dim strTextLine As String
Dim CellRow As Long
Open "c:\temp\t.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strTextLine
If Mid(strTextLine, 2, 13) = "Directory of " Then
strPath = Trim(Mid(strTextLine, 15)) & "\"
GoTo loopnext
End If
If Mid(strTextLine, 6, 1) = "/" Then
If Mid(strPath, 4, 4) = "I386" Then GoTo loopnext
If Mid(strPath, 4, 6) = "DRVLIB" Then GoTo loopnext
If Mid(strPath, 4, 8) = "FOCALPNT" Then GoTo loopnext
strFile = Mid(strTextLine, 40)
ActiveCell.Offset(CellRow, 0) = strPath & strFile
ActiveCell.Offset(CellRow, 2) = strTextLine
CellRow = CellRow + 1
End If
loopnext:
Loop
Close #1
Call sndPlaySound32("tada.wav", 0)
Call sndPlaySound32("C:\Aol40\filedone.wav", 0)
End Sub
___________________________________________________________________________________
_________________
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
Sub PlayWhileActive()
Dim Make_A_Break 'allow change while running
loopnext:
If Len(Trim(ActiveCell.Value)) = 0 Then Exit Sub
If Trim(ActiveCell.Offset(0, 1)) = "" Then _
Call sndPlaySound32(ActiveCell.Value, 0)
Make_A_Break = DoEvents 'yield to system tasks
ActiveCell.Offset(1, 0).Activate
GoTo loopnext
End Sub
___________________________________________________________________________________
_________________
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V_
_v__V__v__V__v__V
Function PlayOne()
Call sndPlaySound32(ActiveCell.Value, 0)
End Function
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
'============ These would go into the sheet =====
Private Sub Worksheet_BeforeDoubleClick(ByVal Target _
As Excel.Range, Cancel As Boolean)
Cancel = True 'Get out of edit mode
innerfunction
End Sub
___________________________________________________________________________________
_________________
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
����������������������������������
v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V_
_v__V__v__V__v__V
Private Sub innerfunction()
Application.Run "personal.xls!PlayOne"
Application.EnableEvents = False
ActiveCell.Offset(1, 0).Activate
Application.EnableEvents = True
End Sub
___________________________________________________________________________________
_________________
'====== no additional references required ======a
^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^__^_
_^__^__^__^__^__^
����������������������������������
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
����������������������������������
v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V__v__V_
_v__V__v__V__v__V
Sub PlayWavFile()
'leo.heuser@get2net.dk, December 3, 2001
Dim FullFileName As String
' FullFileName = "C:\WINDOWS\MEDIA\Microsoft Office 2000\Glass.wav"
FullFileName = Selection
ActiveWorkbook.FollowHyperlink Address:=FullFileName
End Sub
___________________________________________________________________________________
_________________

(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��+��
+��+��+��+��+��+
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^
^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<*^/<
*^/<*^/<*^/<*^/<*

����������������������������������
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
����������������������������������

H="Wrapping Formulas In An Error Test"


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
''''''''''''''''''''''''''''' 'First version%
1-d'''''''''''''
''''
''''''''''''''''
'''' 'Oftentimes I have a range filled with formulas that as such work%
2-d'''''''''''''
'''' ' correctly, but need an error checking mechanism. Take for example%
3-d'''''''''''''
'''' ' the following simple situation:%
4-d'''''''''''''
''''
''''''''''''''''
'''' ' %
5-d'''''''''''''
'''' 'If cell A3 contains no data or a zero, the result in C3 will be%
6-d'''''''''''''
'''' ' #DIV/0!%
7-d'''''''''''''
''''
''''''''''''''''
'''' 'If you dont want the errors to show, the solution is simple: test for%
8-d'''''''''''''
'''' ' zero:%
9-d'''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
=IF(A3=0,"",B3/A3)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
'''' 'But I tend to have much more complicated formulas, in which it is not%
1-d'''''''''''''
'''' ' always just one cell that might cause an error of some sort, so I%
2-d'''''''''''''
'''' ' need to wrap the entire formula in an error check. I thought it%
3-d'''''''''''''
'''' ' might be useful to have a generic little tool that lets you specify%
4-d'''''''''''''
'''' ' how to wrap the current function in a cell with an error test.%
5-d'''''''''''''
''''
''''''''''''''''
'''' 'Here is the first try at a subroutine:%
6-d'''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
Sub ChangeFormulas()
Dim oCell As Range
Dim sFormula As String
Dim sInput As String
Static sFormulaTemplate As String
If sFormulaTemplate = "" Then
sFormulaTemplate = "=IF(ISERROR(_form_),"""",_form_)"
End If
sInput = InputBox("Enter base formula", , sFormulaTemplate)
If sInput = "" Then Exit Sub
sFormulaTemplate = sInput
For Each oCell In Selection
sFormula = Replace(sFormulaTemplate, "_form_", Right(oCell.Formula,
Len(oCell.Formula) - 1))
oCell.Formula = sFormula
Next
End Sub
___________________________________________________________________________________
_________________
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
''''''''''''''''''''''''''''' 'So how does this work?%
1-d'''''''''''''
''''
''''''''''''''''
'''' 'You select the cells with the formulas that need worked over.%
2-d'''''''''''''
'''' 'Then run the sub. An Input box is shown with a default template to%
3-d'''''''''''''
'''' ' change the formula:%
4-d'''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
=IF(ISERROR(_form_),"",_form_)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
'''' 'What this means is that the current formula in the cell is going to%
1-d'''''''''''''
'''' ' be placed at each location where it says "_form_". Edit the formula%
2-d'''''''''''''
'''' ' template to match your need and click OK.%
3-d'''''''''''''
''''
''''''''''''''''
'''' 'Because sFormulaTemplate is declared as Static, the utility remembers%
4-d'''''''''''''
'''' ' the template for a next time you use it.% 5-
d'''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''

_______________________________________________________________________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Dimensioning variables (#dim)"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''
'''' 'Dimensioning variables for use with Options Explicit. If you have%
1-d'''''''''''''
'''' ' simply used Dim xyz as variant you can find out the actual type that%
2-d'''''''''''''
'''' ' you used with MsgBox typename(xyz) so you can replace variant by%
3-d'''''''''''''
'''' ' its actual type. Similarly MsgBox TypeName(Selection) can be use%
4-d'''''''''''''
'''' ' to tell what the selection is. [See Slow Response]% 5-
d'''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Sub ExportToTextFiles()"

Sub ExportToTextFiles()
Dim FirstRow As Integer, LastRow As Integer, MyFileName As String, MyRow As
Integer, MyStr As String

' change these values to the start row and end row for your notes.
' if you have to use a range you'll need a double loop below
FirstRow = 1
LastRow = 4

For MyRow = FirstRow To LastRow


MyFileName = "C:\formtest" & Str(MyRow) & ".txt"

If DoesFileExist(MyFileName) = 0 Then
Open MyFileName For Output As #1 ' create a new file and record if file does
not exist
Else
Open MyFileName For Append As #1 ' append a record if file does already exist
End If

' loop through each row of the table


MyStr = Cells(MyRow, 1).Value
Print #1, MyStr
Close #1
Next

MsgBox "Done"
End Sub

Function DoesFileExist(FileName As String) As Byte


' returns 1 if FileName exists, otherwise 0
If Dir(FileName, vbNormal) <> "" Then
DoesFileExist = 1
Else
DoesFileExist = 0
End If
End Function

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

H="Getting a File Name

by Allen Wyatt (last updated October 18, 2008)

If you are writing a VBA macro in Excel, you may have a need to allow the user to
specify a file they want from the disk. Fortunately, you can access the standard
Open dialog box from within VBA and use it to return just a file name. The
following example subroutine shows how this is done:
Sub GetFName()
Dim FName As Variant
Dim Msg As String

FName = Application.GetOpenFilename()
If FName <> False Then
Msg = "You chose " & FName
MsgBox Msg
Else
'Cancel was pressed
End If
End Sub
___________________________________________________________________________________
_________________

When you run this macro, you will see the standard Open dialog box used in Excel.
The user can select a file, and when they click on Open, the file name (including
the full path) is assigned to the variable FName. If the user clicks on the Cancel
button, then FName is set equal to False. (Thus the test for that in the code.)
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
___________________________________________________________________________________
_________________

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@_(@
_(@_(@_(@_(@_(@_(
_)*(_)*-)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_)*_
)*_)*_)*_)*_)*_)*
(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^_(^
_(^_(^_(^_(^_(^_(^

*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!^/!
^/!^/!^/!^/!^/!^/!^
!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?>*<!^?
>*<!^?>*<!^?>*<!^?>
/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/][/]
[/][/][/][/][/][/
\
+\_\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=-\=
-\=-\=-_\=-\=-\-
}?}?}/}/}/]/}/]/]?}/}/}/}?}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}?]/}
?]/}?]/}?]/}?]/}?
><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)(><)
(><)(><)(><)(><)(><
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!{}!
{}!{}!{}!{}!{}!{}!{}!
___________________________________________________________________________________
_________________
|+__|+__|+__|+__|+__|+__|+__|+__|+__|+__|+___|+__|+___|+___|+____|+__|+__|+___|
+___|+_||+__|+__|+__|+_
_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)
(_)(_)(_)(_)(_)(_
*&*^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*&^*
&^*&^*&^*&^*&^

You might also like