Debraj
Excel Ninja
Hi Friends,
I am unable to select Multiple Sheets at once. I don't know, where I am missing something, but its just ruining my day
Main Problem is in ShtAry (Array Of Sheet). Its adding Sheets to array. I can check the same at Immediate window by
[/pre]
Regards,
Deb
I am unable to select Multiple Sheets at once. I don't know, where I am missing something, but its just ruining my day
Main Problem is in ShtAry (Array Of Sheet). Its adding Sheets to array. I can check the same at Immediate window by
Code:
? ShtAry(78).Name
But Unable to select all the sheet's at once...
Please can someone go through the below coding and provide some knowledge in Array..
PS: Due to pressure of BOSS, I have solved the issue, but not satisfied with bypass method...
[pre]Sub PrintLabels(Filename As String)
Dim shtAry()
Application.ScreenUpdating = False
With ActiveWorkbook
lrints = .Sheets(1).Range("A" & .Sheets(1).Cells.Rows.Count).End(xlUp).Row
ThisWorkbook.Sheets("SL").Visible = True
For i = 2 To lrints
ThisWorkbook.Sheets("SL").Copy After:=ActiveWorkbook.Sheets(1)
'----------------------
' Some useless filling in the Sheet..
' You can assume Sheet("SL") as a template of Shipping Label
' .Sheets("sl").Range("A14") = .Sheets(1).Range("T" & i)
' .Sheets("sl").Range("C14") = .Sheets(1).Range("U" & i)
' and Many more...
'----------------------
' Adding New Sheet to Sheet Array
Order = .Sheets(1).Range("K" & i)
Sheets("sl").Name = Order
ReDim Preserve shtAry(i - 2)
shtAry(i - 2) = Order
Next i
' Unable to select Multiple Sheet as I need to Print all Labels into a single PDF
'=====
Sheets(shtAry).Select
'=====
'----------------------
' Currently using the below to overcome the issue.
' For d = 2 To ActiveWorkbook.Worksheets.Count
' ActiveWorkbook.Sheets(d).Select (False)
' Next d
'----------------------
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "Vendor Order Sheet " & Format(Now(), "DDMMYY") & "" & Filename & " - Chandoo's Orders - " & _
Format(Now(), "DDMMYY") & ".pdf"
Application.DisplayAlerts = False
'=====
Sheets(shtAry).Delete
'=====
'----------------------
' Currently using the below to overcome the issue.
' ActiveWindow.SelectedSheets.Delete
'----------------------
Application.DisplayAlerts = True
End With
End Sub
Regards,
Deb