Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rows("2:2").Select
- ActiveWindow.FreezePanes = True
- Dim r As Range
- Set r = ActiveCell
- Range("A2").Select
- With ActiveWindow
- .FreezePanes = False
- .ScrollRow = 1
- .ScrollColumn = 1
- .FreezePanes = True
- .ScrollRow = r.Row
- End With
- r.Select
- With ActiveWindow
- .SplitColumn = 0
- .SplitRow = 1
- End With
- ActiveWindow.FreezePanes = True
- Application.ScreenUpdating = True
- Cells(2, 1).Select
- ActiveWindow.FreezePanes = True
- Option Explicit
- Sub xls_Build__Report()
- Dim xlApp As Excel.Application, ws As Worksheet, wb As Workbook
- Dim fn As String
- Set xlApp = CreateObject("Excel.Application")
- xlApp.DisplayAlerts = False
- xlApp.Visible = True
- Set wb = xlApp.Workbooks.Add
- With wb
- .Sheets(1).Name = "Report"
- With .Sheets("Report")
- 'report generation here
- End With
- 'This is where the Freeze Pane is dealt with
- 'Freezes top row
- With xlApp.ActiveWindow
- .SplitColumn = 0
- .SplitRow = 1
- .FreezePanes = True
- End With
- fn = CurrentProject.Path & "ReportsReport_" & Format(Date, "yyyymmdd") & ".xlsx"
- If CBool(Len(Dir(fn, vbNormal))) Then Kill fn
- .SaveAs FileName:=fn, FileFormat:=xlOpenXMLWorkbook
- End With
- Close_and_Quit:
- wb.Close False
- xlApp.Quit
- End Sub
- Rows("2:2").Select
- ActiveWindow.FreezePanes = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement