Closed Thread
Results 1 to 6 of 6

Macro - Find column headed date and insert 2 new columns after it

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Macro - Find column headed date and insert 2 new columns after it

    Hi all,

    I have a LOT of data (>10,000 rows long and about 15 columns wide) which I regularly have to go through and insert two columns after the column headed 'Date'. Although I will always have a heading titled 'Date' the size and places of my heading vary - Date will not always be in column C.

    Therefore I am trying to write a macro that will automatically search row1 for 'Date' and add two columns after it - could anyone help me with this please? It sounds so simple!

    I have tried recording a macro to change but... well, it didn't really work!

    Thanks in advance for your help.
    Last edited by Jessica.Bush; 08-12-2010 at 04:59 AM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro - Find column headed date and insert 2 new columns after it

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Re: Macro - Find column headed date and insert 2 new columns after it

    Thank you!

  4. #4
    Registered User
    Join Date
    06-01-2012
    Location
    denver
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro - Find column headed date and insert 2 new columns after it

    Hi guys,

    I having the similar issues. I have 500 plus files, where some start with Column A as "lost frames" header with data and other start with Column A as "sync loss second", Column B as "Link Loss Seconds and then Column C as "lost frames". How do I insert two blank rows at the starting to all the files that has Column A as "lost frames". Help is appreciated.

  5. #5
    Registered User
    Join Date
    06-01-2012
    Location
    denver
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro - Find column headed date and insert 2 new columns after it

    so far,

    if I do this, then I am able to add columns in front of Column A where Cloumn A1 valus is lost frames.

    Sub InsertColumns()
    '
    ' InsertColumns Macro
    Selection.Find("lost frames", MatchCase:=True).Offset(2, 0).Resize(, 2).EntireColumn.Insert
    '
    End Sub

    But for other files where the 1st and 2nd Column are Column A as "sync loss second", Column B as "Link Loss Seconds, I want to use the range that only checks lost frames for column A1. if not do not do anything.

    Thanks
    Deepak

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro - Find column headed date and insert 2 new columns after it

    Deepak,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

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

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