Consulting

Results 1 to 6 of 6

Thread: Inserting a row or a column

  1. #1

    Inserting a row or a column

    Hello Everybody,

    I am comparing 2 sets of data's. The number of rows or columns will not be constant every-time when i run this comparison.

    I want to know how to insert a row or a column when the data is missing/extra in either of the data. for e.g. if the 3rd column is missing in the 2nd data, i want to insert a new column in the 2nd data.

    Thanks in advance,
    Prashanth Vakkund

  2. #2
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    A small sample workbook would help.
    Peace of mind is found in some of the strangest places.

  3. #3
    I hope this will give a clear idea on what I have explained in by query.

    [VBA]DATA-1
    Sale Jan Feb Mar Apr May
    S1 12 23 49 82 56
    S2 34 86 33 37 42
    S3 54 76 46 45 23
    S4 38 56 59 81 67
    S5 67 54 90 29 69
    S6 23 45 16 78 28


    DATA-2
    Sale Jan Feb Mar May
    S1 12 23 49 56
    S2 34 86 33 42
    S4 38 56 59 67
    S5 67 54 90 69
    S6 23 45 16 28

    OUTPUT
    DATA-1 DATA-2
    Sale Jan Feb Mar Apr May Sale JanFeb Mar May
    S1 12 23 49 82 56 S1 12 23 49 56
    S2 34 86 33 37 42 S2 34 86 33 42
    S3 54 76 46 45 23
    S4 38 56 59 81 67 S4 38 56 59 67
    S5 67 54 90 29 69 S5 67 54 90 69
    S6 23 45 16 78 28 S6 23 45 16 28
    [/VBA]

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You can post a workbook using Manage Attachments in the Go Advanced reply section. Your layout of data can affect the solution.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    I have attached the sample data. Can anyone let me know how to insert a row or/and column as shown in the xls?

    Thanks

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try this for inserting rows. The code requires a list of all row values to be referenced, which I have added to Sheet 2. This could be automated if required.
    To insert columns, copy and ajdust the code to work horizontally, rather than vertically. If you get stuck, let us know.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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