+ Reply to Thread
Results 1 to 2 of 2

VBA coding for inserting column based on pervious cell

Hybrid View

  1. #1
    Registered User
    Join Date
    01-16-2014
    Location
    St. Paul MN
    MS-Off Ver
    Excel 2010
    Posts
    1

    VBA coding for inserting column based on pervious cell

    Hi,

    I can seem to figure out how to insert a column after a Certain cell value in row 2.

    So

    Apr May
    2011 2012 2013 2011 2012 2013
    0 0 0 0 0 0
    0 0 0 0 0 0
    0 0 0 0 0 2
    0 0 0 0 0 0
    0 0 0 10 14 0
    0 5 0 10 4 3
    0 0 0 0 0 0
    So I would like the column always pasted after 2013?

    Please help

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA coding for inserting column based on pervious cell

    Maybe:

    Sub littleOne()
    Dim i As Long
    For i = ActiveSheet.UsedRange.Columns.count + 1 To 2 Step -1
        If Cells(2, i).Previous = "2013" Then Cells(2, i).EntireColumn.Insert
    Next i
    End Sub
    Last edited by JOHN H. DAVIS; 01-16-2014 at 03:07 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro coding for inserting an object
    By shznik in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2012, 11:14 AM
  2. colour coding cell based on value of another
    By Brontosaurus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2010, 09:42 AM
  3. Find Data & Paste in pervious column on multiple sheets
    By excelgrrl in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-20-2009, 10:34 PM
  4. Replies: 7
    Last Post: 06-28-2008, 10:40 AM
  5. [SOLVED] Inserting row based on value in cell in Column C
    By Anonymous CHief in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-09-2005, 09:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1