+ Reply to Thread
Results 1 to 10 of 10

VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

  1. #1
    Registered User
    Join Date
    02-28-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Lightbulb VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    Hello Everyone,

    This is my first post regarding VBA Macros so bear with me!

    The last couple of weeks ive been developing a macro but ive hit a snag and i think its probably very simple to resolve but after hours of forum browsing, ive come out more stuck than before. Heres what im trying to achieve:

    Im trying to insert an entire row above two cells in two seperate columns that have a combination of numbers for example:

    If Cells in Column G=0 and Cells in Column H=1, Then insert row above those cells. The Data in my excel sheet are as below:

    Column G Column H
    1 0 0
    2 0 1
    3 0 2
    4 0 3

    and i basically want to insert a row above Row 2 where G=0 and H=1.

    The reason i want to Macro this is because im going to duplicate the macro for various other combinations such as G=1 + H=1, G=2 + H=1 and so on..

    Any help would be much appreciated.

  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 Macro to Insert Row Depending on Two Cell Values in seperate Columns

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-28-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    Hey John,

    Doesnt seem to have any affect on the report :S

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

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    Can you attach a file with some sample data in which it does not work? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  5. #5
    Registered User
    Join Date
    02-28-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    Sure,

    The data is a mess at the moment but the target is to add the row above G1:H1 where the values are 0 & 1, and i will repeat the macro for 1 & 1, 2 & 1 etc.
    Attached Files Attached Files

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

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    Normally row 1 is a header row. Try:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-28-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    You sir deserve a drink!

    That has worked perfectly, and ive modified it to work on the additional variables as well.

    Thank you very much for your help John.

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

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    You're welcome. Glad to help out and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

  9. #9
    Registered User
    Join Date
    02-28-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    All done, even added to your reputation,

    Thanks again

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

    Re: VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns

    BTW, Welcome to the Forum. I noticed you just joined today.

+ 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. Replies: 21
    Last Post: 02-03-2014, 02:43 PM
  2. Macro to Insert Picture depending on cell detail
    By lewhardy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2014, 11:56 AM
  3. Macro to insert cell values in another sheet depending on value and format
    By adw223 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2013, 03:57 PM
  4. [SOLVED] Email macro depending on values in 2 Columns.
    By pladan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-25-2012, 06:42 AM
  5. [SOLVED] Insert Textbox values to seperate rows/columns
    By thompssm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2005, 05:55 PM

Tags for this Thread

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