+ Reply to Thread
Results 1 to 8 of 8

For-loop problem in copying of cells

  1. #1
    Registered User
    Join Date
    12-18-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    24

    For-loop problem in copying of cells

    Hello everyone. Can someone explain to me why the following code doesn't work properly?

    Please Login or Register  to view this content.
    What I want to do is the following: I have multiple sheets and with the first for loop I want to go through each sheet starting from sheet3.By using the second for loop i want everytime to copy the values from Sheet1 starting at 12 row and 6th column up to 15 row and 6th column and afterwards paste these values to each sheet at a specific range(I23). My problem is that the result of this code is, that it always pastes only the value which corresponds to i =15.

    Thank you for your help

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: For-loop problem in copying of cells

    Within the For loop you are coping each of the four cell, but you are pasting them to the same location in the destination sheet!
    Gary's Student

  3. #3
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: For-loop problem in copying of cells

    if i understand you correctly you dont need a second loop to copy
    Please Login or Register  to view this content.
    Give Feedback and Click(*)

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: For-loop problem in copying of cells

    Try:

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 01-24-2014 at 09:26 AM.

  5. #5
    Registered User
    Join Date
    12-18-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: For-loop problem in copying of cells

    Thank you all for the replies. I think though that I didn't explain it correctly. So lets say that in Sheet 1 we have
    the values from F12:F15. What i want is, to copy the value which is at cell F12 and paste it at cell I23 of sheet3, then copy the value of cell F13 and paste it at cell I23 of Sheet4 etc.With the above codes the result it to copy all the values from f12:f15 to each sheet. Sorry for the misunderstanding.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: For-loop problem in copying of cells

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-18-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: For-loop problem in copying of cells

    Thank you very much, it works :D

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: For-loop problem in copying of cells

    You're welcome. Glad to help out and thanks for the feedback. Please comply with Forum Rule No. 9.


    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] nested loop for copying range: error no cells were found
    By Edejager in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2013, 08:52 AM
  2. Loop cycle not copying correct cells
    By HDMI in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2013, 10:53 AM
  3. Copying cells and transposing it using loop
    By shivek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2011, 02:08 PM
  4. copying cells when column A equals certain text, loop function?
    By djl304 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2009, 09:13 PM
  5. Copying static cells in a loop....Paste Special problems
    By knox5731@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2006, 04:45 PM

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