• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to insert column based on some category

arun198322654

New Member
Hi Everyone

I have one situation where i had to insert column in my table bases one category.

In row b, there are two company code GB00 and GB40, I need to insert column after each GB40 column. Can any one help me with VBA code. I had attached the file which will explain it better. Please have a look and help me.

Thanks in advance.
 

Attachments

  • GB40.xlsx
    11.3 KB · Views: 4
Code:
Option Explicit

Sub nsertgb40()
    Dim lc As Long
    Dim i As Long
    lc = Cells(6, Columns.Count).End(xlToLeft).Column
    For i = lc To 1 Step -1
        If Cells(6, i) = "GB40" Then
            Cells(6, i + 1).EntireColumn.Insert
        End If
    Next i

End Sub
 
Back
Top