+ Reply to Thread
Results 1 to 7 of 7

Macro to compare two colums and copy rows if data matches.

  1. #1
    Registered User
    Join Date
    03-30-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    10

    Unhappy Macro to compare two colums and copy rows if data matches.

    Hi,

    I have a macro below which is used to compare two column of different sheet and is the value matches, it pasts the corresponding values into sheet1.
    THe problem is I don't want it to copy whole row. I want to copy a particular column data only and replace them in sheet1 with the corresponding Colum.

    Please Login or Register  to view this content.
    Last edited by avinash.aswani; 09-11-2013 at 02:54 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Help with current macro.

    Please Login or Register  to view this content.
    Last edited by patel45; 09-10-2013 at 11:43 AM.
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help with current macro.

    Hi, avinash.aswani,

    you should mention what column is wanted now as opposed to Column A in the original code:

    Please Login or Register  to view this content.
    And maybe you should think about changing the thread title as well - not the best of all available descriptions.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    03-30-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Help with current macro.

    Hi,
    Column A of both sheet is compared.
    Now if suppose "row3 of column A in sheet1" is matching with "row2 of column A in master sheet". then data from "column C in row 2 of master" should be copied and pasted in "sheet1 row3 column B".

  5. #5
    Registered User
    Join Date
    03-30-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Help with current macro.

    Hi
    threat title change as per forum rule.

    Regards,
    Avinash

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Help with current macro.

    Quote Originally Posted by avinash.aswani View Post
    Hi
    threat title change as per forum rule.

    Regards,
    Avinash
    Thanks for understanding. Finally-as you see- is not so difficult to use a correct title. and generally to post according forum rules!
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to compare two colums and copy rows if data matches.

    Hi, Avinash ,

    I assumed that the columns were equal and thus used a variable for it. Change the code to read
    Please Login or Register  to view this content.
    Offset(0, 1): 0 stands for no row offset (same row, positive number would mean number of rows down), 1 stands for an offset to the right of one column. Negative values would stand for rows up or columns to the left.

    Ciao,
    Holger

+ 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] Macro to merge duplicate rows unique values - current macro not working
    By aimeecrystalaid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-06-2013, 03:42 PM
  2. [SOLVED] VBA Macro - Alteration of current macro to ignore hidden cells :)
    By Defratos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2013, 07:45 AM
  3. [SOLVED] creating a macro that inserts the current date in the same cell everytime the macro is run
    By katie1994 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-14-2012, 07:59 PM
  4. Macro to sort an activity sheet by current week and current + last 1 and 2 weeks
    By engineering_excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2011, 11:28 AM
  5. [SOLVED] Name of Current Macro running?
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-24-2005, 09:50 AM

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