+ Reply to Thread
Results 1 to 4 of 4

I want a macro to merge a sheet of two column data to another sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Smile I want a macro to merge a sheet of two column data to another sheet

    Hi:

    Please help me to write a macro for the following problem:
    I have two sheets.
    Sheet1:
    Column A Column B
    ABCuc24556 To be postponed
    ABCuc24557 Discussion will be later
    ABCuc40001 Not reproducble now


    Sheet2:
    Column A Column B
    ABCuc24556 To be fixed in next release
    ABCuc24557 Discussion will be later
    ABCuc34567 New issue to be reproduced

    After macro execution, Sheet2 should be merged in to Sheet1. Sheet1 will be as follows:
    Column A Column B
    ABCuc24556 To be fixed in next release
    ABCuc24557 Discussion will be later
    ABCuc40001 Not reproducble now
    ABCuc34567 New issue to be reproduced


    kasi

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: I want a macro to merge a sheet of two column data to another sheet

    Sub MergeTwoSheets()
    Dim LR as Long
    
    Sheets("Sheet1").Copy After:=Sheets(Sheets.Count)
    Sheets("Sheet2").Usedrange.Offset(1).Copy Range("A" & Rows.Count).End(xlUp).Offset(1)
    
    Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes
    
    LR = Range("A" & Rows.Count).End(xlUp).row
    
    Range("AA2:AA" & LR).Formula = "=COUNTIF($A$2:$A2, $A2)"
    
    Rows(1).AutoFilter
    Rows(1).AutoFilter 27, ">1"
    LR = Range("A" & Rows.Count).End(xlUp).row
    If LR > 1 Then Range("A2:A" & LR).Entirerow.Delete xlShiftUp
    Activesheet.AutoFilterMode=False
    
    Range("AA:AA").ClearContents
    
    End Sub
    Last edited by JBeaucaire; 10-22-2012 at 02:47 PM. Reason: Corrected code
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-19-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: I want a macro to merge a sheet of two column data to another sheet

    "Copile error: Sub or Function not defined" pop up comes at Row(1).AutoFilter

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: I want a macro to merge a sheet of two column data to another sheet

    Code corrected above, should be Rows

+ Reply to 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