Closed Thread
Results 1 to 6 of 6

Excel 2007 : (Copy Data from sheet 1 to sheet 2) (Pasting Option)

  1. #1
    Registered User
    Join Date
    05-08-2010
    Location
    usa
    MS-Off Ver
    execel 2007
    Posts
    3

    (Copy Data from sheet 1 to sheet 2) (Pasting Option)

    I need help with copying data to sheet 2, there seems to be a problem with my macro it copy's data in sheet 2, but it always pastes data in A2 Row, B2, C2 and so on... I can't seems to understand what is wrong. (what should I do if I want the data to paste below A2 Row for example: A5, B5 or C5.

    I use this macro in my work sheet

    Option Explicit

    Sub CopyData()
    Dim NextRw As Long
    Dim wsMn As Worksheet, wsIp As Worksheet

    Set wsIp = Sheets("Input")
    Set wsMn = Sheets("Main")
    [NextRw = wsIp.Range("A" & Rows.Count).End(xlUp).Row + 1]

    wsIp.Range("A" & NextRw).Value = wsMn.Range("N2").Value
    wsIp.Range("B" & NextRw).Value = wsMn.Range("C6").Value
    wsIp.Range("C" & NextRw).Value = wsD.wsMn("J5").Value

    End Sub
    Last edited by sunny1978; 05-12-2010 at 07:12 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Data from sheet 1 to sheet 2 (Pasting Option)

    Hi Sunny... Welcome to the forum.

    Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to EDIT that post above and put code tags around that code you used. (Like shown here) Please go back and fix that.

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


    There's also an error, you didn't change one of the wsD reference when you adjusted my macro for your use, you need to adjust all the references.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-08-2010
    Location
    usa
    MS-Off Ver
    execel 2007
    Posts
    3

    (Copy Data from sheet 1 to sheet 2) (Pasting Option)

    Hi, JBeaucaire,
    sorry for the misunderstanding..
    you didn't understand my question...

    I tried the code you posted, but it's not helping, its still doing the same thing.
    its still pasting data in sheet 2 in the second row..a2, b2, c2

    [NextRw = wsIp.Range("A" & wsIp.Rows.Count).End(xlUp).Row + 1]

    (My question was, I want the data to be paste in A5, B5, C5..)

    Set wsIp = Sheets("Input")
    Set wsMn = Sheets("Main")
    [NextRw = wsIp.Range("A" & wsIp.Rows.Count).End(xlUp).Row + 1]

    wsIp.Range("A" & NextRw).Value = wsMn.Range("N2").Value
    wsIp.Range("B" & NextRw).Value = wsMn.Range("C6").Value
    wsIp.Range("C" & NextRw).Value = wsMn.Range("J5").Value

    End Sub
    Last edited by sunny1978; 05-12-2010 at 07:16 AM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Copy Data from sheet 1 to sheet 2 (Pasting Option)

    Quote Originally Posted by sunny1978 View Post
    Hi, JBeaucaire,
    sorry for the misunderstanding..
    you didn't understand my question...
    ...and you didn't understand and respond to JB's request. Please go back and add code tags to your post.

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    05-08-2010
    Location
    usa
    MS-Off Ver
    execel 2007
    Posts
    3

    Re: (Copy Data from sheet 1 to sheet 2) (Pasting Option)

    Hey I am sorry about that, I am very new to this forum, that's why I got confuse with that tag thing. I didn't realize what you exactly meant by tag. but OK I got it now.

    Please let me know if I am still doing something wrong...

    thank you for all your help..

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

    Re: (Copy Data from sheet 1 to sheet 2) (Pasting Option)

    Your thread is being closed for non compliance with our rules. Please PM me when you have read the forum rules RULES and made the changes to your post accordingly, i will then unlock your post so you may continue with the thread!

    Post Closed
    Hope that helps.

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

    Free DataBaseForm example

Closed 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