+ Reply to Thread
Results 1 to 3 of 3

How To Deal With Varying Number of Rows

  1. #1
    Registered User
    Join Date
    07-17-2007
    Posts
    5

    How To Deal With Varying Number of Rows

    Hi,

    I'm trying to create a macro that takes data from one sheet of a workbook and places it in another sheet of the same workbook. The problem I'm having is that it needs accomodate varying numbers of rows.

    Let's say I have 10 rows of data and I copy them over from one sheet to the destination sheet. I need to create 10 more rows underneath, 10 under that and then 10 more under that. The problem I'm having is that when I use ctrl-shift-down to go to the last row, it is recording that cell in the code. I'm not writing the code, rather recording my keystrokes.

    What is the simplest way to accomplish my goal? This has to work whether it is 10 rows, 15, 100, 1000, etc.

    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523
    Hi there,

    If necessary, tweak the following code which will copy a dynamic range which is continuous, starts at A1 and there is more than one column of data to be copied:

    Please Login or Register  to view this content.
    HTH

    Robert

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What code are you copying with? You can select varying ranges with various methods similar to messnj's suggestion or use inbuilt UsedRange or CurrentRegion, depending on your layout.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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