0% found this document useful (0 votes)
29 views

VBA Code Note by IIVMI

The document contains VBA code to format and analyze an invoice summary worksheet. It copies the worksheet, sorts data, colors cells based on values, renames columns, deletes unnecessary columns, and creates new sheets based on unique values in a column.

Uploaded by

Aarnaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

VBA Code Note by IIVMI

The document contains VBA code to format and analyze an invoice summary worksheet. It copies the worksheet, sorts data, colors cells based on values, renames columns, deletes unnecessary columns, and creates new sheets based on unique values in a column.

Uploaded by

Aarnaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Sub VBAcode_work()

'List to make sheets

Dim lcol As Long

Dim jcol As Long

Dim lrow As Long

Dim erow As Long

Dim a As Long

Dim rng As Range

Dim specific_column As Range

Worksheets("Invoice Summary").Activate

lcol = Worksheets("Invoice Summary").Cells(2, Columns.Count).End(xlToLeft).Column 'lastcol no in


invoice summary

'ActiveSheet.Shapes.Range(Array("Picture 2")).Select

'Selection.Delete

Range("1:1").Insert

Range("A1").Select

For q = 1 To lcol

'concatenate

Cells(1, q).Value = Cells(2, q).Value & "-" & Cells(3, q).Value

Next

'lastrow no in invoice summary

lrow = Worksheets("Invoice Summary").Cells(Rows.Count, 2).End(xlUp).Row

Set rng = Range(Cells(3, 1), Cells(lrow, lcol))


'criteria for sort

Set specific_column = Worksheets("Invoice Summary").Range("C:C")

rng.Select

'sorting

rng.Sort Key1:=specific_column, Order1:=xlAscending, Header:=xlYes

'Sheets.Add After:=ActiveSheet

Sheets("Invoice Summary").Copy after:=ActiveSheet

ActiveSheet.Name = "Invoice Summary-1"

Dim R As Range

For h = 1 To lcol

If Cells(1, h).Value = "Supplier Data-RCM" Then

Set R = Range(Cells(1, h), Cells(lrow, h))

For Each Cell In R

If Cell.Value = "Yes" Then

Cell.Interior.ColorIndex = 8

End If

Next

End If

If Cells(1, h).Value = "Supplier Data-Revision" Then

Set R = Range(Cells(1, h), Cells(lrow, h))

For Each Cell In R

If Cell.Value = "Original" Then

Cell.Interior.ColorIndex = 40
End If

Next

End If

Next

'start formatting of 1 row

Range(Cells(1, 1), Cells(1, lcol)).Select

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

'/ end of formatting


For i = 1 To lcol

If Cells(1, i).Value = "-" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "-Match Result" Then

Cells(1, i).Value = "Match Result"

End If

If Cells(1, i).Value = "-Supplier GSTIN" Then

Cells(1, i).Value = "Supplier GSTIN"

End If

If Cells(1, i).Value = "-Supplier Name" Then

Cells(1, i).Value = "Supplier Name"

End If

If Cells(1, i).Value = "-Supplier State" Then

Cells(1, i).Value = "Supplier State"

End If

If Cells(1, i).Value = "-Business Unit" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "-Doc Type" Then

Cells(1, i).Value = "Doc Type"

End If

' If Cells(1, i).Value = "My Data-Period" Then

' Columns(i).Delete

' End If

' If Cells(1, i).Value = "Supplier Data-Period" Then

' Columns(i).Delete
' End If

If Cells(1, i).Value = "Supplier Data-GSTR-1 Status" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-GSTR-1 Filing Date" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-GSTR-3B Status" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Purchase Type" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Purchase Type" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Taxable Value" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Taxable Value" Then

Columns(i).Delete

End If

' If Cells(1, i).Value = "My Data-IGST" Then

' Columns(i).Delete

' End If

' If Cells(1, i).Value = "Supplier Data-IGST" Then

' Columns(i).Delete

' End If

If Cells(1, i).Value = "-IGST Difference" Then


Columns(i).Delete

End If

' If Cells(1, i).Value = "My Data-CGST" Then

' Columns(i).Delete

' End If

' If Cells(1, i).Value = "Supplier Data-CGST" Then

' Columns(i).Delete

' End If

If Cells(1, i).Value = "-CGST Difference" Then

Columns(i).Delete

End If

' If Cells(1, i).Value = "My Data-SGST" Then

' Columns(i).Delete

' End If

' If Cells(1, i).Value = "Supplier Data-SGST" Then

' Columns(i).Delete

' End If

If Cells(1, i).Value = "-SGST Difference" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Cess" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Cess" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "-Cess Difference" Then

Columns(i).Delete

End If
If Cells(1, i).Value = "-ERP Ref No" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Ref Doc No" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Ref Doc No" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Ref Doc Date" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Ref Doc Date" Then

Columns(i).Delete

End If

' If Cells(1, i).Value = "Supplier Data-Revision" Then

' Columns(i).Delete

' End If

If Cells(1, i).Value = "Supplier Data-Original Doc No" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Original Doc Date" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Amendment Doc No" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Amendment Doc Date" Then

Columns(i).Delete
End If

If Cells(1, i).Value = "My Data-Action" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Action" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Notes" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "Supplier Data-Notes" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Keywords" Then

Columns(i).Delete

End If

If Cells(1, i).Value = "My Data-Doc Date" Then

Columns(i).NumberFormat = "dd/mm/yy"

End If

If Cells(1, i).Value = "Supplier Data-Doc Date" Then

Columns(i).NumberFormat = "dd/mm/yy"

End If

Next

' list for match results


Range("A3").Select

Range(Selection, Selection.End(xlDown)).Select

Selection.Copy

Sheets.Add after:=ActiveSheet

ActiveSheet.Name = "Sheetnamelist"

Range("A1").Select

ActiveSheet.Paste

Application.CutCopyMode = False

ActiveSheet.Range(Selection, Selection.End(xlDown)).RemoveDuplicates Columns:=1, Header:=xlYes

Range("A2").Select

lastcell = Worksheets("Sheetnamelist").Cells(Rows.Count, 1).End(xlUp).Row

For t = 2 To lastcell

' to create sheets as per match results

newname = Worksheets("Sheetnamelist").Cells(t, 1).Value

Sheets.Add after:=Sheets(Sheets.Count)

ActiveSheet.Name = newname

Worksheets("Invoice Summary-1").Activate 'to copy first rows

Range("1:1").Copy

Worksheets(newname).Activate

ActiveSheet.Paste

Next

For j = 2 To lastcell

newname = Worksheets("Sheetnamelist").Cells(j, 1).Value


' erow = Worksheets(newname).Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row

For k = 4 To lrow

If Worksheets("Invoice Summary-1").Cells(k, 1).Value = newname Then

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

' If Worksheets(newname).Cells(a + 1, 2).Value = Worksheets(newname).Cells(a, 2).Value


Then

' Rows(a + 2).EntireRow.Insert

' End If

Worksheets("Invoice Summary-1").Activate

End If

Next

Worksheets(newname).Activate

If ActiveSheet.Name = "Missing in Supplier Data" Then

With Worksheets(newname)

.Columns(1).ColumnWidth = 15 'match result

.Columns(2).ColumnWidth = 17 'Supplier GSTIN

.Columns(3).Columns.AutoFit 'Supplier Name


.Columns(4).ColumnWidth = 12 'Supplier State

.Columns(5).ColumnWidth = 9 'Doc Type

.Columns(6).ColumnWidth = 17 'My Data Doc no

'.Columns(7).ColumnWidth = 12 'Supplier Data Doc no

.Columns(8).ColumnWidth = 10 'My Data Doc dt

'.Columns(9).ColumnWidth = 10 'Supplier Data Doc dt

'.Columns(10).ColumnWidth = 7.2 'My Data Period

'.Columns(11).ColumnWidth = 7.2 'Supplier Data Period

'.Columns(12).ColumnWidth = 10 'My Data Place of Supply

'.Columns(13).ColumnWidth = 10 'Supplier Data place of supply

'.Columns(14).ColumnWidth = 3 'My Data RCM

'.Columns(15).ColumnWidth = 3 'Supplier Data RCM

.Columns(16).ColumnWidth = 8 'My Data IGST

'.Columns(17).ColumnWidth = 8 'Supplier Data IGST

.Columns(18).ColumnWidth = 8 'My Data CGST

'.Columns(19).ColumnWidth = 8 'Supplier Data CGST

.Columns(20).ColumnWidth = 8 'My Data SGST

'.Columns(21).ColumnWidth = 8 'Supplier Data SGST

.Columns(22).ColumnWidth = 10 'My Data Total Tax

'.Columns(23).ColumnWidth = 10 'Supplier Data Total Tax

'.Columns(24).ColumnWidth = 10 'Tax Difference

.Columns(25).ColumnWidth = 12 'My Data Doc Value

'.Columns(26).ColumnWidth = 12 'Supplier Data Doc Value

'.Columns(27).ColumnWidth = 10 'Supplier Data Revision

End With

jcol = Worksheets(newname).Cells(1, Columns.Count).End(xlToLeft).Column 'lastcol no in


newname sheet
For n = 1 To jcol

If Cells(1, n).Value = "Match Result" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Place of Supply" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Doc No" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Doc Date" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Period" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Period" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-IGST" Then

Columns(n).Delete

End If
If Cells(1, n).Value = "Supplier Data-CGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-SGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Doc Value" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Revision" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Total Tax" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Place of Supply" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "-Tax Difference" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Place of Supply" Then

Columns(n).Delete

End If

Next

Range("1:3").Insert

Cells(1, 1).Value = Worksheets("Overview").Cells(5, 3).Value & " - " &


Worksheets("Overview").Cells(8, 3).Value

Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname
Cells(3, 1).Value = "Report by www.accountants-gst.com"

End If

If ActiveSheet.Name = "Matching" Then

With Worksheets(newname)

.Columns(1).ColumnWidth = 15 'match result

.Columns(2).ColumnWidth = 17 'Supplier GSTIN

.Columns(3).Columns.AutoFit 'Supplier Name

.Columns(4).ColumnWidth = 12 'Supplier State

.Columns(5).ColumnWidth = 9 'Doc Type

.Columns(6).ColumnWidth = 12 'My Data Doc no

'.Columns(7).ColumnWidth = 12 'Supplier Data Doc no

.Columns(8).ColumnWidth = 10 'My Data Doc dt

'.Columns(9).ColumnWidth = 10 'Supplier Data Doc dt

'.Columns(10).ColumnWidth = 7.2 'My Data Period

'.Columns(11).ColumnWidth = 7.2 'Supplier Data Period

'.Columns(12).ColumnWidth = 10 'My Data Place of Supply

'.Columns(13).ColumnWidth = 10 'Supplier Data place of supply

'.Columns(14).ColumnWidth = 3 'My Data RCM

'.Columns(15).ColumnWidth = 3 'Supplier Data RCM

.Columns(16).ColumnWidth = 8 'My Data IGST

'.Columns(17).ColumnWidth = 8 'Supplier Data IGST

.Columns(18).ColumnWidth = 8 'My Data CGST

'.Columns(19).ColumnWidth = 8 'Supplier Data CGST

.Columns(20).ColumnWidth = 8 'My Data SGST


'.Columns(21).ColumnWidth = 8 'Supplier Data SGST

.Columns(22).ColumnWidth = 10 'My Data Total Tax

'.Columns(23).ColumnWidth = 10 'Supplier Data Total Tax

'.Columns(24).ColumnWidth = 10 'Tax Difference

.Columns(25).ColumnWidth = 12 'My Data Doc Value

'.Columns(26).ColumnWidth = 12 'Supplier Data Doc Value

'.Columns(27).ColumnWidth = 10 'Supplier Data Revision

End With

jcol = Worksheets(newname).Cells(1, Columns.Count).End(xlToLeft).Column 'lastcol no in


newname sheet

For n = 1 To jcol

If Cells(1, n).Value = "My Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Doc No" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Doc Date" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Period" Then

Columns(n).Delete

End If
If Cells(1, n).Value = "Supplier Data-Period" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-IGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-CGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-SGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Doc Value" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Revision" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Total Tax" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Place of Supply" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "-Tax Difference" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Match Result" Then

Columns(n).Delete
End If

If Cells(1, n).Value = "Supplier Data-Place of Supply" Then

Columns(n).Delete

End If

Next

Range("1:3").Insert

Cells(1, 1).Value = Worksheets("Overview").Cells(5, 3).Value & " - " &


Worksheets("Overview").Cells(8, 3).Value

Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname

Cells(3, 1).Value = "Report by www.accountants-gst.com"

End If

If ActiveSheet.Name = "Missing in My Data" Then

With Worksheets(newname)

.Columns(1).ColumnWidth = 15 'match result

.Columns(2).ColumnWidth = 17 'Supplier GSTIN

.Columns(3).Columns.AutoFit 'Supplier Name

.Columns(4).ColumnWidth = 12 'Supplier State

.Columns(5).ColumnWidth = 9 'Doc Type

'.Columns(6).ColumnWidth = 12 'My Data Doc no

.Columns(7).ColumnWidth = 17.5 'Supplier Data Doc no

'.Columns(8).ColumnWidth = 10 'My Data Doc dt

.Columns(9).ColumnWidth = 10 'Supplier Data Doc dt


'.Columns(10).ColumnWidth = 7.2 'My Data Period

'.Columns(11).ColumnWidth = 7.2 'Supplier Data Period

'.Columns(12).ColumnWidth = 10 'My Data Place of Supply

'.Columns(13).ColumnWidth = 10 'Supplier Data place of supply

'.Columns(14).ColumnWidth = 3 'My Data RCM

.Columns(15).ColumnWidth = 3 'Supplier Data RCM

'.Columns(16).ColumnWidth = 8 'My Data IGST

.Columns(17).ColumnWidth = 8 'Supplier Data IGST

'.Columns(18).ColumnWidth = 8 'My Data CGST

.Columns(19).ColumnWidth = 8 'Supplier Data CGST

'.Columns(20).ColumnWidth = 8 'My Data SGST

.Columns(21).ColumnWidth = 8 'Supplier Data SGST

'.Columns(22).ColumnWidth = 10 'My Data Total Tax

.Columns(23).ColumnWidth = 10 'Supplier Data Total Tax

'.Columns(24).ColumnWidth = 10 'Tax Difference

'.Columns(25).ColumnWidth = 12 'My Data Doc Value

.Columns(26).ColumnWidth = 12 'Supplier Data Doc Value

.Columns(27).ColumnWidth = 10 'Supplier Data Revision

End With

jcol = Worksheets(newname).Cells(1, Columns.Count).End(xlToLeft).Column 'lastcol no in


newname sheet

For n = 1 To jcol

If Cells(1, n).Value = "Match Result" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Doc No" Then

Columns(n).Delete
End If

If Cells(1, n).Value = "My Data-Doc Date" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "-Tax Difference" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Period" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Period" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-IGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-CGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-SGST" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Doc Value" Then


Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Total Tax" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "-Tax Difference" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Place of Supply" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Place of Supply" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-RCM" Then

Cells(1, n).Value = "S-RCM"

End If

Next

Range("1:3").Insert

Cells(1, 1).Value = Worksheets("Overview").Cells(5, 3).Value & " - " &


Worksheets("Overview").Cells(8, 3).Value

Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname

Cells(3, 1).Value = "Report by www.accountants-gst.com"

Cells(1, 6).Value = "RCM Invoice"

Cells(1, 6).Interior.ColorIndex = 8

Cells(1, 7).Value = "Amended Invoice"

Cells(1, 7).Interior.ColorIndex = 40
End If

If ActiveSheet.Name = "Almost Matching" Then

With Worksheets(newname)

.Columns(1).ColumnWidth = 15 'match result

.Columns(2).ColumnWidth = 17 'Supplier GSTIN

.Columns(3).Columns.AutoFit 'Supplier Name

.Columns(4).ColumnWidth = 12 'Supplier State

.Columns(5).ColumnWidth = 9 'Doc Type

.Columns(6).ColumnWidth = 17 'My Data Doc no

.Columns(7).ColumnWidth = 17 'Supplier Data Doc no

.Columns(8).ColumnWidth = 10 'My Data Doc dt

.Columns(9).ColumnWidth = 10 'Supplier Data Doc dt

.Columns(10).ColumnWidth = 8 'My Data Period

.Columns(11).ColumnWidth = 8 'Supplier Data Period

'.Columns(12).ColumnWidth = 10 'My Data Place of Supply

'.Columns(13).ColumnWidth = 10 'Supplier Data place of supply

'.Columns(14).ColumnWidth = 3 'My Data RCM

'.Columns(15).ColumnWidth = 3 'Supplier Data RCM

.Columns(16).ColumnWidth = 8 'My Data IGST

.Columns(17).ColumnWidth = 8 'Supplier Data IGST

.Columns(18).ColumnWidth = 8 'My Data CGST

.Columns(19).ColumnWidth = 8 'Supplier Data CGST


.Columns(20).ColumnWidth = 8 'My Data SGST

.Columns(21).ColumnWidth = 8 'Supplier Data SGST

.Columns(22).ColumnWidth = 10 'My Data Total Tax

.Columns(23).ColumnWidth = 10 'Supplier Data Total Tax

'.Columns(24).ColumnWidth = 10 'Tax Difference

.Columns(25).ColumnWidth = 10 'My Data Doc Value

.Columns(26).ColumnWidth = 10 'Supplier Data Doc Value

'.Columns(27).ColumnWidth = 10 'Supplier Data Revision

End With

jcol = Worksheets(newname).Cells(1, Columns.Count).End(xlToLeft).Column 'lastcol no in


newname sheet

For n = 1 To jcol

If Cells(1, n).Value = "Match Result" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Place of Supply" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Place of Supply" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-RCM" Then

Columns(n).Delete
End If

If Cells(1, n).Value = "-Tax Difference" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Revision" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Total Tax" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Total Tax" Then

Columns(n).Delete

End If

Next

Range("1:3").Insert

Cells(1, 1).Value = Worksheets("Overview").Cells(5, 3).Value & " - " &


Worksheets("Overview").Cells(8, 3).Value

Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname

Cells(3, 1).Value = "Report by www.accountants-gst.com"

End If

If ActiveSheet.Name = "Not Matching" Then

With Worksheets(newname)

.Columns(1).ColumnWidth = 15 'match result

.Columns(2).ColumnWidth = 17 'Supplier GSTIN


.Columns(3).Columns.AutoFit 'Supplier Name

.Columns(4).ColumnWidth = 12 'Supplier State

.Columns(5).ColumnWidth = 9 'Doc Type

.Columns(6).ColumnWidth = 12 'My Data Doc no

.Columns(7).ColumnWidth = 12 'Supplier Data Doc no

.Columns(8).ColumnWidth = 10 'My Data Doc dt

.Columns(9).ColumnWidth = 10 'Supplier Data Doc dt

'.Columns(10).ColumnWidth = 7.2 'My Data Period

'.Columns(11).ColumnWidth = 7.2 'Supplier Data Period

.Columns(12).ColumnWidth = 10 'My Data Place of Supply

.Columns(13).ColumnWidth = 10 'Supplier Data place of supply

'.Columns(14).ColumnWidth = 3 'My Data RCM

'.Columns(15).ColumnWidth = 3 'Supplier Data RCM

.Columns(16).ColumnWidth = 8 'My Data IGST

.Columns(17).ColumnWidth = 8 'Supplier Data IGST

.Columns(18).ColumnWidth = 8 'My Data CGST

.Columns(19).ColumnWidth = 8 'Supplier Data CGST

.Columns(20).ColumnWidth = 8 'My Data SGST

.Columns(21).ColumnWidth = 8 'Supplier Data SGST

.Columns(22).ColumnWidth = 10 'My Data Total Tax

.Columns(23).ColumnWidth = 10 'Supplier Data Total Tax

.Columns(24).ColumnWidth = 10 'Tax Difference

.Columns(25).ColumnWidth = 12 'My Data Doc Value

.Columns(26).ColumnWidth = 12 'Supplier Data Doc Value

.Columns(27).ColumnWidth = 10 'Supplier Data Revision

End With

jcol = Worksheets(newname).Cells(1, Columns.Count).End(xlToLeft).Column 'lastcol no in


newname sheet
For n = 1 To jcol

If Cells(1, n).Value = "Match Result" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-Period" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-Period" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "My Data-RCM" Then

Columns(n).Delete

End If

If Cells(1, n).Value = "Supplier Data-RCM" Then

Columns(n).Delete

End If

Next

Range("1:3").Insert

Cells(1, 1).Value = Worksheets("Overview").Cells(5, 3).Value & " - " &


Worksheets("Overview").Cells(8, 3).Value

Cells(2, 1).Value = "Purchase Invoices & Credit Notes - " & newname

Cells(3, 1).Value = "Report by www.accountants-gst.com"


End If

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

You might also like