+ Reply to Thread
Results 1 to 2 of 2

Automatic range adjustment when copying data

  1. #1
    Registered User
    Join Date
    03-14-2006
    Posts
    23

    Automatic range adjustment when copying data

    Excel experts...

    I have two worksheets in my workbook, one of which goes to a master worksheet and selects a range of cells. The macro I use is:

    ActiveCell.FormulaR1C1 = "=Dates!RC"
    Range("A2").Select
    Selection.AutoFill Destination:=Range("A2:A500"), Type:=xlFillDefault
    Range("A2:A500").Select

    I use a range from 2 to 500 because the information rarely exceeds 500 cells. How can I have the macro go to the main worksheet and only collect what data is there rather than just 500 rows of data, most of which I don't use and look ugly in the worksheet.

    Many thanks for your help. This site and the people on it is a savior.

  2. #2
    Tom Ogilvy
    Guest

    RE: Automatic range adjustment when copying data

    Dim rng as Range
    With Worksheets("Dates")
    set rng = .Range(.Cells(2,1),.Cells(2,1).End(xldown))
    End with
    with Worksheets("Master")
    .Range(rng.Address).FormulaR1C1 = "=Dates!RC"
    end with

    --
    Regards,
    Tom Ogilvy


    "Sandeman" wrote:

    >
    > Excel experts...
    >
    > I have two worksheets in my workbook, one of which goes to a master
    > worksheet and selects a range of cells. The macro I use is:
    >
    > ActiveCell.FormulaR1C1 = "=Dates!RC"
    > Range("A2").Select
    > Selection.AutoFill Destination:=Range("A2:A500"),
    > Type:=xlFillDefault
    > Range("A2:A500").Select
    >
    > I use a range from 2 to 500 because the information rarely exceeds 500
    > cells. How can I have the macro go to the main worksheet and only
    > collect what data is there rather than just 500 rows of data, most of
    > which I don't use and look ugly in the worksheet.
    >
    > Many thanks for your help. This site and the people on it is a savior.
    >
    >
    > --
    > Sandeman
    > ------------------------------------------------------------------------
    > Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
    > View this thread: http://www.excelforum.com/showthread...hreadid=523117
    >
    >


+ 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