Dear All, i m creating a file which i facing a issue in run the code every time i got the error on below
I m getting error on this (Shtnames(UBound(Shtnames)) = c.value)
Sub Print_Printer()
Dim c As Range
Dim lastrow, i As Integer
Dim Shtnames As Variant
ReDim Shtnames(0)
lastrow = Sheets("DATA").Columns("H").Cells(Rows.Count).End(xlUp).row
For Each c In Sheets("DATA").Range("H2:H" & lastrow)
If c.value <> 0 Then
Sheets("BILL").Range("E7").value = c.value
Sheets("BILL").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = c.value <======== getting error over there
Shtnames(UBound(Shtnames)) = c.value
ReDim Preserve Shtnames(UBound(Shtnames) + 1)
End If
Next c
ReDim Preserve Shtnames(UBound(Shtnames) - 1)
Sheets(Shtnames).Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Application.DisplayAlerts = False
Sheets(Shtnames).Delete
Application.DisplayAlerts = True
End Sub
Bookmarks