+ Reply to Thread
Results 1 to 5 of 5

Thread: VBA Macro to copy entire row to another sheet

  1. #1
    Registered User
    Join Date
    02-11-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    VBA Macro to copy entire row to another sheet

    Hi I need your help here, please!

    I have created a very basic VBA code for highlighting expiration date of the contract( please see the attached document). However, I need another option and I got stuck with it. I would like to copy these highlighted expired dates (including its whole row) into a new sheet, so-called Expired Contracts but not deleting these information from the original sheet (Sheet1). Sheet1 will be the main document which it is populated all the time and sometimes from time to time the highlighted expired contracts have to be copied into Expired Contracts sheet. I though that I could have in the Sheet1 a Button(Control Panel) which could action a copy upon its clicking. Can you help me out here , please ?

    Regards,
    Jo
    Attached Files Attached Files

  2. #2
    Forum Guru Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,023

    Re: VBA Macro to copy entire row to another sheet

    I've not looked at your example but assuming the highlighted row is the activerow this code will work
    ActiveCell.EntireRow.Copy Destination:= Sheets("Sheet2").range("A" & rows.count).end(xlup).offset(1,0)
    Hope that helps

    Google Me
    Find me located here Simon Lloyd
    and what i'm about Here
    The above is NOT a link to a forum so is NOT against Rule 13

  3. #3
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,566

    Re: VBA Macro to copy entire row to another sheet

    Hi,

    Use a Data Filter.
    Copy your field headers to your expired contracts sheet (say sheet2) and add the name 'DataOut' to this row of labels, add a criteria range with =NOW() in the second cell of the criteria range - the first is of course the label 'Expiry Date. Name thecriteria range say "crit", create a dynamic range for your sheet1 data, say 'data' and then add the following code.

    Sheet1.Range("Data").AdvancedFilter Action:=xlFilterCopy, CopyToRange:= Sheet2.Range("DataOut"), CriteriaRange:=sheet2.Range("crit")
    Richard Buttrey

    If this was useful then please rate it appropriately.

    Click the small star icon at the bottom left of my post.

  4. #4
    Registered User
    Join Date
    02-11-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA Macro to copy entire row to another sheet

    Hi Simon,

    Thank you for such quick response!
    Unfortunately, sometimes I need to copy bunch of the data in one go ( not only the active one) but at least I know where to start. I will google it more . Thank you!
    Jo

  5. #5
    Registered User
    Join Date
    02-11-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA Macro to copy entire row to another sheet

    Thank you Richard!
    Will do! Thanks guys for your help!

    Jo

+ 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.2.0