(Solved) – VBA to create two columns after last column, specific row with data

(solved)-–-vba-to-create-two-columns-after-last-column,-specific-row-with-data

Trying to create a VBA that adds two named columns after the last column with data in row 16. I also want the named columns to be in row 16
I also want the VBA to go to Next workbook if rows “20th Percentile” and “80th Percentile” already exist

Sub create_columns_test2()
'insert two columns on every sheet in workbook after last column with data
    'named 20th and 80th Percentile

    Dim wb As Workbook
    Dim WS As Worksheet
    Dim x As Integer

    For Each WS In Worksheets

        If WS.Cells.Find("20th Percentile", "80th Percentile") = True Then Next
        x = Sheet.UsedRange.Columns.Count
        ' I want the code to use row 16 to check for last data
        .Cells(1, x   1) = "20th Percentile"
        .Cells(1, x   2) = "80th Percentile"
        ' I want these names in row 16


    Next WS


End Sub

I also get a “Compile Error” at If WS.Cells.Find("20th Percentile", "80th Percentile") = True Then Next

Leave a Reply

Your email address will not be published. Required fields are marked *