Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Oct 2005
    Location
    Cambridgeshire, USA
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    list macro (Excel 2003)

    Hello,
    I have created a list that I need to copy to another worksheet. The list was created via the menus of Data-List-Create. I want to create a macro to copy this list to another sheet in the same file. I tried using the record and this is what I get. The problem is that I don't know what the Range is going to be. It could be as little as a row or as much as 10 rows. How can I change the range so it can copy all the information? Any help would be great. Thanks.

    ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$8:$S$25"), , xlNo).Name = _
    "List1"
    Range("A8:S27").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("A17").Select
    ActiveSheet.Paste

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: list macro (Excel 2003)

    Try

    ActiveSheet.ListObjects.Add(xlSrcRange, Range("A8").CurrentRegion, , xlNo).Name = "List1"
    Range("A8").CurrentRegion.Copy Destination:=Sheets("Sheet1").Range("A17")

    CurrentRegion expands a cell (or cells) until a blank row or column is encountered.
    The above code avoids selecting cells explicitly.

Posting Permissions

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