PDA

View Full Version : split as per Map sheet



fatalcore
02-19-2012, 06:41 PM
Hi,
I want a code when called that will simply freeze pane the sheets as mapped in the sheet named "Map". For example if Sheet1 is 4 then in sheet 1 after 4 rows the sheet will be freezed and so on .
I am uploading a dummy sheet for reference.
Thanks in advance.

CatDaddy
02-21-2012, 03:09 PM
what do you mean by freeze?

fatalcore
02-21-2012, 07:11 PM
Hi Catdaddy,
Thanks for replying.
I have already worked on the main file manually. However here is the code which solves the problem, this might help the other people in the future.
Thanks and regards,
Sub FreezePanes()

Dim Cell As Range
Dim R As Long
Dim Rng As Range
Dim RngEnd As Range
Dim Wks As Worksheet

Set Rng = Worksheets("Map").Range("A2")
Set RngEnd = Rng.Parent.Cells(Rows.Count, Rng.Column).End(xlUp)
If RngEnd.Row < Rng.Row Then Exit Sub Else Set Rng = Rng.Parent.Range(Rng, RngEnd)

For Each Cell In Rng
Set Wks = Worksheets(Cell.Value)
R = Cell.Offset(0, 1).Value + 1

Wks.Activate
Wks.Rows(R).EntireRow.Select
ActiveWindow.FreezePanes = True
Next Cell

End Sub