Hi,
I need some help with my code. It works ok, but I'm loosing one of my headings in the split, my top one (row1)
row 1 headings are merged columns, B:G "Product" H:M "Actor" N:Q "Follow-up" and R.AI "Report card"
row 2 headings are one for each column.
See the code below, please help me
Sub masterlista()
Application.ScreenUpdating = False
Dim data_sh As Worksheet
Set data_sh = ThisWorkbook.Sheets("test1")
Dim setting_sh As Worksheet
Set setting_sh = ThisWorkbook.Sheets("Settings")
Dim nwb As Workbook
Dim nsh As Worksheet
setting_sh.Range("A:A").Clear
data_sh.AutoFilterMode = False
data_sh.Range("A:A").Copy setting_sh.Range("A1")
setting_sh.Range("A:A").RemoveDuplicates 1, x1Yes
Dim i As Integer
For i = 2 To Application.CountA(setting_sh.Range("A:A"))
data_sh.UsedRange.AutoFilter 1, setting_sh.Range("A" & i).Value
Set nwb = Workbooks.Add
Set nsh = nwb.Sheets(1)
data_sh.UsedRange.SpecialCells(xlCellTypeVisible).Copy nsh.Range("A1")
'''''nsh.UsedRange.Rows("1").RowHeight = 15
nsh.UsedRange.Rows("1").RowHeight = 120
nsh.UsedRange.Columns("A").Hidden = True
nsh.UsedRange.Columns("B").ColumnWidth = 25
nsh.UsedRange.Columns("C:D").ColumnWidth = 16
nsh.UsedRange.Columns("E").ColumnWidth = 35
nsh.UsedRange.Columns("F").ColumnWidth = 13
nsh.UsedRange.Columns("G").ColumnWidth = 27
nsh.UsedRange.Columns("H").ColumnWidth = 55
nsh.UsedRange.Columns("I").ColumnWidth = 19
nsh.UsedRange.Columns("J").ColumnWidth = 22
nsh.UsedRange.Columns("K").ColumnWidth = 23
nsh.UsedRange.Columns("L:M").ColumnWidth = 24
nsh.UsedRange.Columns("N:O").ColumnWidth = 79
nsh.UsedRange.Columns("P").ColumnWidth = 18
nsh.UsedRange.Columns("Q").ColumnWidth = 35
nsh.UsedRange.Columns("R").ColumnWidth = 55
nsh.UsedRange.Columns("S:AI").ColumnWidth = 22
nwb.SaveAs setting_sh.Range("H3").Value & "/" & "Översikt av era artiklar som ingick i 2020 års kartläggning_" & setting_sh.Range("A" & i).Value & ".xlsx"
nwb.Close Flase
data_sh.AutoFilterMode = False
Next i
setting_sh.Range("A:A").Clear
MsgBox "Done"
End Sub
I need some help with my code. It works ok, but I'm loosing one of my headings in the split, my top one (row1)
row 1 headings are merged columns, B:G "Product" H:M "Actor" N:Q "Follow-up" and R.AI "Report card"
row 2 headings are one for each column.
See the code below, please help me
Sub masterlista()
Application.ScreenUpdating = False
Dim data_sh As Worksheet
Set data_sh = ThisWorkbook.Sheets("test1")
Dim setting_sh As Worksheet
Set setting_sh = ThisWorkbook.Sheets("Settings")
Dim nwb As Workbook
Dim nsh As Worksheet
setting_sh.Range("A:A").Clear
data_sh.AutoFilterMode = False
data_sh.Range("A:A").Copy setting_sh.Range("A1")
setting_sh.Range("A:A").RemoveDuplicates 1, x1Yes
Dim i As Integer
For i = 2 To Application.CountA(setting_sh.Range("A:A"))
data_sh.UsedRange.AutoFilter 1, setting_sh.Range("A" & i).Value
Set nwb = Workbooks.Add
Set nsh = nwb.Sheets(1)
data_sh.UsedRange.SpecialCells(xlCellTypeVisible).Copy nsh.Range("A1")
'''''nsh.UsedRange.Rows("1").RowHeight = 15
nsh.UsedRange.Rows("1").RowHeight = 120
nsh.UsedRange.Columns("A").Hidden = True
nsh.UsedRange.Columns("B").ColumnWidth = 25
nsh.UsedRange.Columns("C:D").ColumnWidth = 16
nsh.UsedRange.Columns("E").ColumnWidth = 35
nsh.UsedRange.Columns("F").ColumnWidth = 13
nsh.UsedRange.Columns("G").ColumnWidth = 27
nsh.UsedRange.Columns("H").ColumnWidth = 55
nsh.UsedRange.Columns("I").ColumnWidth = 19
nsh.UsedRange.Columns("J").ColumnWidth = 22
nsh.UsedRange.Columns("K").ColumnWidth = 23
nsh.UsedRange.Columns("L:M").ColumnWidth = 24
nsh.UsedRange.Columns("N:O").ColumnWidth = 79
nsh.UsedRange.Columns("P").ColumnWidth = 18
nsh.UsedRange.Columns("Q").ColumnWidth = 35
nsh.UsedRange.Columns("R").ColumnWidth = 55
nsh.UsedRange.Columns("S:AI").ColumnWidth = 22
nwb.SaveAs setting_sh.Range("H3").Value & "/" & "Översikt av era artiklar som ingick i 2020 års kartläggning_" & setting_sh.Range("A" & i).Value & ".xlsx"
nwb.Close Flase
data_sh.AutoFilterMode = False
Next i
setting_sh.Range("A:A").Clear
MsgBox "Done"
End Sub