Macro utilities for Excel

Sub ClearData()

' ClearData Macro

For RowC = 5 To Worksheets.Count

RowX = "A" & RowC 'Modify Letter for Column

Range(RowX).Select

Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

Range("I16:J16").Select

Selection.ClearContents

Sheets("Report").Select

Next RowC

ActiveWorkbook.Save

End Sub

Sub NoRun()

' NoRun Macro

For RowC = 5 To 9

RowX = "A" & RowC 'Modify Letter for Column

'

Range(RowX).Select

Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

Range("J16").Select

ActiveCell.FormulaR1C1 = "No Run"

Sheets("Report").Select

Next RowC

ActiveWorkbook.Save

End Sub

Public Sub Get_Report()

Dim i As Long

For i = 2 To Worksheets.Count

ActiveSheet.Cells(i, 1).Value = Worksheets(i).Name

ActiveSheet.Cells(i, 2).Value = Worksheets(i).Cells(3, 8).Value

ActiveSheet.Cells(i, 3).Value = Worksheets(i).Cells(3, 3).Value

ActiveSheet.Cells(i, 4).Value = Worksheets(i).Cells(16, 10).Value

ActiveSheet.Cells(i, 5).Value = Worksheets(i).Cells(16, 9).Value

Next i

End Sub

Sub hyperlink()

'

' hyperlink Macro

'

Application.ScreenUpdating = False

Dim hyper As String ' hyperlink variable

'

Dim endrow As Integer

Dim RowX As String ' Cell to change

Dim RowC As Integer 'row Counter

Dim wb As Workbook

Dim ws As Worksheet

Set wb = ThisWorkbook

Set ws = wb.ActiveSheet

endrow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

RowC = 2

Do Until RowC > endrow

RowX = "A" & RowC 'Modify Letter for Column

Range(RowX).Select

If Range(RowX).Value <> "" Then ' skips cell if blank

hyper = Range(RowX).Value

Range(RowX).Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _

"'" + hyper + "'!A" + CStr(RowC) _

, TextToDisplay:= _

hyper

End If

RowC = RowC + 1

Loop

Application.ScreenUpdating = True

End Sub

No comments:

Post a Comment