VBA Code Note by IIVMI
VBA Code Note by IIVMI
Dim a As Long
Worksheets("Invoice Summary").Activate
'ActiveSheet.Shapes.Range(Array("Picture 2")).Select
'Selection.Delete
Range("1:1").Insert
Range("A1").Select
For q = 1 To lcol
'concatenate
Next
rng.Select
'sorting
'Sheets.Add After:=ActiveSheet
Dim R As Range
For h = 1 To lcol
Cell.Interior.ColorIndex = 8
End If
Next
End If
Cell.Interior.ColorIndex = 40
End If
Next
End If
Next
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = -0.249977111117893
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = 0
.Weight = xlThin
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns(i).Delete
End If
End If
End If
End If
End If
Columns(i).Delete
End If
End If
' Columns(i).Delete
' End If
' Columns(i).Delete
' End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
' Columns(i).Delete
' End If
' Columns(i).Delete
' End If
End If
' Columns(i).Delete
' End If
' Columns(i).Delete
' End If
Columns(i).Delete
End If
' Columns(i).Delete
' End If
' Columns(i).Delete
' End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
If Cells(1, i).Value = "-ERP Ref No" Then
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
' Columns(i).Delete
' End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).Delete
End If
Columns(i).NumberFormat = "dd/mm/yy"
End If
Columns(i).NumberFormat = "dd/mm/yy"
End If
Next
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets.Add after:=ActiveSheet
ActiveSheet.Name = "Sheetnamelist"
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A2").Select
For t = 2 To lastcell
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = newname
Range("1:1").Copy
Worksheets(newname).Activate
ActiveSheet.Paste
Next
For j = 2 To lastcell
For k = 4 To lrow
Worksheets("Invoice Summary-1").Rows(k).Copy
Worksheets(newname).Activate
a = Worksheets(newname).Cells(Rows.Count, 1).End(xlUp).Row
Worksheets(newname).Cells(a + 1, 1).Select
ActiveSheet.Paste
' End If
Worksheets("Invoice Summary-1").Activate
End If
Next
Worksheets(newname).Activate
With Worksheets(newname)
End With
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
If Cells(1, n).Value = "Supplier Data-CGST" Then
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Next
Range("1:3").Insert
Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname
Cells(3, 1).Value = "Report by www.accountants-gst.com"
End If
With Worksheets(newname)
End With
For n = 1 To jcol
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
If Cells(1, n).Value = "Supplier Data-Period" Then
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Next
Range("1:3").Insert
Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname
End If
With Worksheets(newname)
End With
For n = 1 To jcol
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
End If
Next
Range("1:3").Insert
Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname
Cells(1, 6).Interior.ColorIndex = 8
Cells(1, 7).Interior.ColorIndex = 40
End If
With Worksheets(newname)
End With
For n = 1 To jcol
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Next
Range("1:3").Insert
Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname
End If
With Worksheets(newname)
End With
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Columns(n).Delete
End If
Next
Range("1:3").Insert
Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.2)
.RightMargin = Application.InchesToPoints(0.2)
.TopMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.25)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 95
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
Next
Worksheets("Invoice Summary").Activate
Rows(1).Delete
Worksheets("Invoice Summary-1").Activate
Rows(2).Delete
Rows(2).Delete
Worksheets("Sheetnamelist").Visible = False
End Sub