Change macro range from column A to B

sachin483

Board Regular
Joined
Mar 31, 2015
Messages
163
Office Version
  1. 2019
Platform
  1. Windows
I want to change the column select range from A to B with top 5 rows freeze in every sheet and then split
VBA Code:
Sub sheets_seperator()
Dim flpath As String
Dim lr As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False

cnt = 1
flpath = Application.InputBox("Enter the file location") & "\"

On Error Resume Next
On Error Resume Next
Sheets("List").Delete

Sheets.Add(After:=Sheets(Sheets.Count)).Name = "List"

Sheets("Rep_1").Select
Columns("a:a").Copy

Sheets("List").Select
Range("A1").PasteSpecial xlPasteValuesAndNumberFormats

Range("A:A").RemoveDuplicates 1, xlYes
Range("A1").Select
Range("A1:A2").EntireRow.Delete
Columns.AutoFit
ActiveSheet.UsedRange.AutoFilter 1, "*Total*"
Sheets("List").AutoFilter.Range.Offset(1).Delete xlShiftUp
ActiveSheet.ShowAllData

Set mstrwb = ThisWorkbook

lr = Sheets("List").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr
Teamname = Cells(i, 1).Value

Workbooks.Add
ActiveWorkbook.SaveAs flpath & Teamname & "- Report" & ".xlsx", FileFormat:=51
Set extr = ActiveWorkbook

For Each ws In mstrwb.Worksheets
ws.Copy After:=extr.Sheets(Sheets.Count)
Next ws

Sheets("List").Delete
Sheets(1).Delete

For Each ws In extr.Sheets
ws.Select

Range("a4").Select
Rows("4:4").Select
       Selection.AutoFilter
Selection.AutoFilter 1, "<>" & "*" & Teamname & "*"

Range("a4").Select
ActiveSheet.AutoFilter.Range.Offset(1).Delete xlShiftUp
ActiveSheet.ShowAllData
Range("a5").Select
Next ws

Sheets(2).Select

ActiveWorkbook.Close True
cnt = cnt + 1
Next i
MsgBox cnt - 1 & " Files created Successfully"

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,224,737
Messages
6,180,670
Members
452,993
Latest member
FDARYABEE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top