+ Reply to Thread
Results 1 to 3 of 3

Comparing two fields and inserting rows

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Gooding, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    13

    Comparing two fields and inserting rows

    Hi...I want to create a Macro that compares two fields. If they match, move to the next row. If field1 is greater than field2, insert a blank field (shift everything down) in field1 until field1 = field 2. If field2 is greater than field1, insert a blank field (shift everything down) in field1 until field1 = field2.
    I've been doing it manually and would like to have a macro do it. In the example below I shifted Field2 down when it didn't match. The next field that would need to shift down is Field2 = 24725. Thank you for any help.

    Field1 Field2
    6947 6947
    7113 7113
    7825
    7873 7873
    9657 9657
    24675 24675
    24688 24725
    24725 24941
    24941 25146
    25146 25170
    25170 25226
    25226 25269
    25269 25505
    25505 25646
    25646 25670
    25670 25697
    25697 25916
    25916 26259
    26259 26377
    26377 26396
    26396 26427
    26424 26477
    26427 26491
    26477 26680
    26491 26768
    26680 26794
    26768 26911
    26794 26976
    26911 26982
    26976 27002
    26982 27004
    27002 27007
    27004 27036
    27007

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Comparing two fields and inserting rows

    Give this a try

    Please Login or Register  to view this content.
    Last edited by maniacb; 04-14-2021 at 05:07 PM. Reason: Updated to account for two conditions

  3. #3
    Registered User
    Join Date
    01-04-2013
    Location
    Gooding, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    13

    Re: Comparing two fields and inserting rows

    Thank you! That worked perfect! I'm sorry I spent so much time on my own trying to figure it out!

+ 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. [SOLVED] How to delete rows based on comparing values in two fields
    By OmniBlue in forum Excel General
    Replies: 5
    Last Post: 09-19-2013, 12:32 PM
  2. Comparing 2 coloumn fields
    By akky91 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-09-2013, 11:47 AM
  3. Replies: 0
    Last Post: 04-10-2013, 11:29 AM
  4. Comparing two columns data and inserting rows
    By scyllanbay in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-11-2012, 11:56 AM
  5. Comparing fields in 2 different spreadsheets
    By bellw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2009, 07:26 AM
  6. Comparing fields in 2 different spreadsheets
    By bellw in forum Excel General
    Replies: 0
    Last Post: 07-22-2009, 05:28 PM
  7. comparing mutple fields on a row with rows in another worksheet
    By SandyUK in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-24-2007, 05:13 AM
  8. [SOLVED] Comparing text fields
    By [email protected] in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-28-2005, 10:05 AM

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