Private Sub Workbook_Open()
Prepare_Table
End Sub
Sub Prepare_Table()
Dim msgInput As Integer
Dim olApp As Outlook.Application
If prepareTable = True Then
msgInput = MsgBox("Table Created do you want to open Outlook and send mail", vbYesNo)
frwdMail
If msgInput = vbYes Then
End If
Else
MsgBox "No Table created", vbOKOnly
End If
End Sub
Function prepareTable() As Boolean
findCells
Dim typeSelection As String
If TypeName(Selection) = "" Then
MsgBox "There is nothing selected, First make the selection and then Run the Macro", vbOKOnly
prepareTable = False
Else
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Style = "Normal"
Selection.UnMerge
Range("C1").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Hidden = True
Range("C36").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Paste
Range("A1:C1").Select
Columns("C:C").EntireColumn.AutoFit
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = True
Range("A:A,B:B").Select
Range("B1").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
ActiveSheet.Cells.SpecialCells(xlCellTypeConstants).Select
Selection.Copy
prepareTable = True
End If
End Function
Function frwdMail()
reportForm.Show
End Function
Function findCells()
Dim keyC, SeverityC, SummaryC As String
Dim keyR, Severity, Summary As String
Dim KeyRange, SeverityRange, SummaryRange As String
Dim lastRowNumber As Long
lastRowNumber = [A:C].Find(What:="*", After:=[C1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Cells.Find(What:="key", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
keyC = Selection.Address
keyR = colLetter(ActiveCell.Column)
Cells.Find(What:="Severity", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
SeverityC = Selection.Address
SeverityR = colLetter(ActiveCell.Column)
Cells.Find(What:="Summary", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
SummaryC = Selection.Address
SummaryR = colLetter(ActiveCell.Column)
KeyRange = keyC & ":" & keyR & lastRowNumber
SeverityRange = SeverityC & ":" & SeverityR & lastRowNumber
SummaryRange = SummaryC & ":" & SummaryR & lastRowNumber
MsgBox KeyRange & ":" & SeverityRange & ":" & SummaryRange, vbOKOnly
Range(KeyRange & "," & SeverityRange & ":" & SummaryRange).Select
''Range(SeverityC & ":" & SeverityR & lastRowNumber).Select
''Range(SummaryC & ":" & SummaryR & lastRowNumber).Select
End Function
Function colLetter(col As Long)
Dim sColumn As String
On Error Resume Next
sColumn = Split(Columns(col).Address(, False), ":")(1)
On Error GoTo 0
colLetter = sColumn
End Function