+ Reply to Thread
Results 1 to 31 of 31

Copying used range from one sheet to another

  1. #1
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Copying used range from one sheet to another

    Morning,

    I'm trying to copy used range data from one tab to another tab, using the header as an identification as to where to copy the data to and from. I need to bare in mind that there maybe a change in data range so need to code it to copy the used data rather than cell range?

    Anyone help,

    I've attached a sample of the data.
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    I am not able to understand your question. Maybe you can try explaining using your attached file?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Apologies,

    On sheet 1 i have the source data, i need to copy this to sheet 2 directly under each of the headings.

    When i copy the data i need to code it so if there is more data than what i have this month it will copy it all rather than the range of data i have this month?

    Does that make more sense?

  4. #4
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Did that help?

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Yes, will the column order in sheet2 always be the same as in sheet1?

  6. #6
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Yes it will, the only thing that will change will be the amount of data.

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Try this code
    Please Login or Register  to view this content.
    Put the code in a standard module.

  8. #8
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Thanks, works very well.

    Thank you

  9. #9
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Silly Question.

    What does this bit mean;

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Apologies to come back to you on this, some of the columns will change postion in the data too, is it possible to code this to copy of columns seperatly based on column header?

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Quote Originally Posted by kenadams378 View Post
    Silly Question.

    What does this bit mean;

    Please Login or Register  to view this content.
    I am using a variable called lrow which means lastrow. It checks which is the last row of data in your sheet. Long is just to denote how much space in memory it needs.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Quote Originally Posted by kenadams378 View Post
    Apologies to come back to you on this, some of the columns will change postion in the data too, is it possible to code this to copy of columns seperatly based on column header?
    This is what i had asked you in post5. Can you explain some more regarding the columns changing position? Do you mean to say the 12 columns will be there but in mixed order? Or there are chances that some of the columns might not be there at all?

  13. #13
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Was does the DIM mean?

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Its a programming term used to declare variables.

  15. #15
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    All the columns will be there but there will other columsn within the sheet that will have forumla's in them.

    I have attached an example.

    Quote Originally Posted by arlu1201 View Post
    This is what i had asked you in post5. Can you explain some more regarding the columns changing position? Do you mean to say the 12 columns will be there but in mixed order? Or there are chances that some of the columns might not be there at all?
    Attached Files Attached Files

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    You have only provided me one sheet. Please upload the sheet containing the data that needs to be copied to this sheet.

  17. #17
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    As requested
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Did you get chance to ook at the extra attachment?

  19. #19
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Will look into this right now.

  20. #20
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Thank you, apologies for the duplicate post.

  21. #21
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Any luck with this, is it possible?

  22. #22
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Can you explain where the entries from sheet1 should go in sheet2? For e.g. sheet1 column A should go to column A in sheet2, sheet1 column B should go to sheet2 column C,etc.

  23. #23
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Each column should be matched using the headers of each column so for example;

    Funding to funding
    Amount to Amount
    Attached Files Attached Files

  24. #24
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Has that helped?

  25. #25
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Use this code
    Please Login or Register  to view this content.
    Put it in a standard module.

  26. #26
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    Morning,

    I'm having an issue with this code

    Please Login or Register  to view this content.
    The error message is 'Application-defined or object defined error?

    Any ideas?

  27. #27
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Attach the file that you are using with this code.

  28. #28
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    The file i'm using is over 70mb

  29. #29
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    The code that i provided in post 25 works with the attachment that you provided in post 23. You have edited the code, hence it could be causing the error. What are you attempting to copy using these lines
    Please Login or Register  to view this content.

  30. #30
    Forum Contributor
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    822

    Re: Copying used range from one sheet to another

    I'm trying to copy columns of data from one sheet to another.

    The columns range in terms of amount of data and position on the final worksheet.

  31. #31
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying used range from one sheet to another

    Yes, you are right. What error did you get when you tried the code in post 25? Also, you added new lines of code as in post 29. What do you want to do in addition to the code i provided, by running those code lines?

+ 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