+ Reply to Thread
Results 1 to 8 of 8

Copy dynamic range from previous sheet and paste after last used row in a range

  1. #1
    Registered User
    Join Date
    11-20-2009
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    25

    Copy dynamic range from previous sheet and paste after last used row in a range

    Hello All,

    I am trying to copy the values from a dynamic range ("C7:E66")on the previous sheet onto the current active sheet, but I need to paste the values after the last used row in a range ("C7:E66")

    I can get it to copy the data on the previous sheet no problem, however I am stuck as it is not pasting after the last used rown on the active sheet that the macro is run from.

    Here is what I have so far

    I appreciate any help offered greatly as I'm pulling my hair out now!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,647

    Re: Copy dynamic range from previous sheet and paste after last used row in a range

    Do not use relative references to sheets in VBA.

    Please Login or Register  to view this content.
    Last edited by snb; 08-05-2010 at 04:26 AM.

  3. #3
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    PA
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Copy dynamic range from previous sheet and paste after last used row in a range

    Quote Originally Posted by Mistweaver View Post
    Hello All,

    I am trying to copy the values from a dynamic range ("C7:E66")on the previous sheet onto the current active sheet, but I need to paste the values after the last used row in a range ("C7:E66")

    I can get it to copy the data on the previous sheet no problem, however I am stuck as it is not pasting after the last used rown on the active sheet that the macro is run from.

    Here is what I have so far

    I appreciate any help offered greatly as I'm pulling my hair out now!

    Please Login or Register  to view this content.
    Hi,

    Not sure if this is what your looking for but maybe try:

    Please Login or Register  to view this content.
    Thank You, Mike

  4. #4
    Registered User
    Join Date
    11-20-2009
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Copy dynamic range from previous sheet and paste after last used row in a range

    Quote Originally Posted by snb View Post
    Do not use relativer references to sheets in VBA.

    Please Login or Register  to view this content.

    Thanks snb, but the reason I am using relative references is that the number of sheets will change weekly and so I cannot use the index number.

    Mike,

    Thanks for helping, but this does not work. It pastes much further down the sheet instead of after the last used row in range C7:E66 which is where I need to paste the data.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,202

    Re: Copy dynamic range from previous sheet and paste after last used row in a range

    Surely this will return the same Ro
    Please Login or Register  to view this content.
    Try attaching a workbook
    Hope that helps.

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

    Free DataBaseForm example

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,647

    Re: Copy dynamic range from previous sheet and paste after last used row in a range

    The last added sheet is always sheets(1)
    the oldest (first) sheet is sheets(sheets.count))
    than this will do

    Please Login or Register  to view this content.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy dynamic range from previous sheet and paste after last used row in a range

    Quote Originally Posted by snb View Post
    The last added sheet is always sheets(1)
    the oldest (first) sheet is sheets(sheets.count))
    That is not true. The sheet on the left of the tab order is sheets(1), the sheet on the right is sheets(sheets.count). The age or timing is irrelevant.
    Remember what the dormouse said
    Feed your head

  8. #8
    Registered User
    Join Date
    11-20-2009
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Copy dynamic range from previous sheet and paste after last used row in a range

    I still haven't had any luck with this so any more help would be greatly appreciated.

    I have attached the workbook.

    Basically I need to copy the figures from the sheet before to the sheet next to it after the last row of data.
    Attached Files Attached Files

+ 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

X vBulletin 4.1.8 Debug Information

  • Page Generation 0.06498 seconds
  • Memory Usage 9,077KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (7)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (8)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (4)navbar_noticebit
  • (6)option
  • (1)postbit_attachment
  • (8)postbit_legacy
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (4)showthread_bookmarksite
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper
  • (1)vbseo_linkbackmenu_entry 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (39):
  • ./vbseo.php
  • ./env.php
  • ./vbseo/includes/functions_vbseo.php
  • ./vbseo/includes/functions_vbseo_pre.php
  • ./vbseo/includes/functions_vbseo_url.php
  • ./vbseo/includes/functions_vbseo_createurl.php
  • ./vbseo/includes/functions_vbseo_db.php
  • ./vbseo/includes/functions_vbseo_vb.php
  • ./vbseo/includes/functions_vbseo_seo.php
  • ./vbseo/includes/functions_vbseo_misc.php
  • ./vbseo/includes/functions_vbseo_crr.php
  • ./vbseo/includes/functions_vbseo_cache.php
  • ./vbseo/includes/functions_vbseo_hook.php
  • ./vbseo/includes/functions_vbseo_startup.php
  • ./includes/config.php
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/functions.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/functions_cforum.php
  • ./includes/functions_facebook.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php
  • ./includes/functions_notice.php 

Hooks Called (47):
  • init_startup
  • friendlyurl_resolve_class
  • database_pre_fetch_array
  • database_post_fetch_array
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • fetch_musername
  • cache_templates
  • template_register_var
  • parse_templates
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • reputation_image
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • showthread_bookmarkbit
  • navbits
  • navbits_complete
  • showthread_complete


Search Engine Friendly URLs by vBSEO 3.6.0 RC 1