+ Reply to Thread
Results 1 to 13 of 13

Copy Range from Sheet2 to Sheet1 through VBA

  1. #1
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    364

    Copy Range from Sheet2 to Sheet1 through VBA

    Hi everyone

    I am sure it's really simple, but even through Google I did not manage to come across a helpful Code for the life of me

    What I basicly need is that Excel copies the Range B:I from Sheet2 to Sheet1 whenever data is entered in Sheet2.

    Note that Sheet1 will be hidden for the user.

    At the same time the value for A:A in sheet1 should be filled in by looking up the value of A:A in Sheet2 and replace it with the value defined in Sheet3
    (allthough once I know how to get the first part this will be easy)


    Edit: I should note, that if a user changes the value of any cell, the value in Sheet1 should change as well

    Anyone who could help?

    Thanks
    FD
    Last edited by FallingDown; 10-26-2012 at 08:31 AM. Reason: Provide more Info

  2. #2
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    364

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    Hi all

    OK, so as I thought, fairly simple

    Please Login or Register  to view this content.
    BUT: How would I exclude Col. A, or limit the code to col B to I?

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

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    You can try this - in the sheet1 code window
    Please Login or Register  to view this content.
    Though this will copy info even if one column is populated, we will need to send a condition that only once a particular column is populated (maybe column I in your case), then the transfer should happen.
    Last edited by arlu1201; 10-26-2012 at 06:33 AM. Reason: Corrected typo.
    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]

  4. #4
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    how do you want this code to work?
    When some one types anywhere in sheet2 the whole row from column B to I gets copyed to Sheet 1?
    Or do you mean when some one types something in column A the same row column B to I gets copyed to sheet 1 where there is the same value?

    It could be much easier if you uploaded an example workbook with a before and after situation.

  5. #5
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    364

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    Hi Arlette

    It ends in runtime error

    --> Shouldnt I be able to define the range in my code beforehand?

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

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    There was a typo there. I corrected my previous post.

    What do you mean by define the range? As per the code, the data from B to I of the target row will get copied starting in column B in the target row of Sheet2.

  7. #7
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    364

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    Hi stojko89

    Whenever a user enters a value in range "B:I" (any row) it should copy the value to the same target, just on sheet1
    So if a User enters "Hello" in Sheet2 to for Cell B4, "Hello" should also appear in Cell B4 on Sheet 1

    The code I posted does exactly that, but for the entire worksheet(s).
    This would not be a problem, would it not be for the fact that I will need different values for col. A in Sheet1
    Last edited by FallingDown; 10-26-2012 at 06:46 AM. Reason: Typo Correction Sheet --> Sheet2

  8. #8
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    Never mind my post... arlu1201 beats me every time
    You just need to set the Intersect the target to only copy if the target value changes in the range of B:I and not if you type a value in column A and you'll be good to go

  9. #9
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    So like this
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    364

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    Thanks to both of you: works great

  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: Copy Range from Sheet2 to Sheet1 through VBA

    Am glad its solved.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    I will do it for you this time.
    Last edited by arlu1201; 10-26-2012 at 07:03 AM.

  12. #12
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    364

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    Hi Arlette

    As said, your code works perfectly fine.
    BUT: Is it possible to have the VALUES copied.
    Cause your copies the formula as well

    Thanks

  13. #13
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Copy Range from Sheet2 to Sheet1 through VBA

    Try using this then:
    Please Login or Register  to view this content.

+ 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