+ Reply to Thread
Results 1 to 4 of 4

Copy Paste loop in multiple tabs

  1. #1
    Registered User
    Join Date
    07-06-2010
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    98

    Copy Paste loop in multiple tabs

    Hi there,

    I am using a loop to have a number put into tab "Batch size calcs" cell "AB2" and then copy the range "X15:AE15" into tab "Tabelle1" for 100 iterations. Then I do the same thing from 101 until 200 and paste it in the tab "Tabelle2". This all works fine but the problem is that in "Tabelle2" the first paste is in row 102 and not in 2. What is wrong with my code? What do I have to change? Please find my code below.

    Thanks in advance for your help.

    Dim lastRow As Long
    Dim x As Integer

    Worksheets("Tabelle1").Range("A2:I20000").Clear
    Worksheets("Tabelle2").Range("A2:I20000").Clear

    For x = 1 To 100

    lastRow = Cells(Rows.Count, 1).End(xlUp).Row

    Sheets("Batch size calcs").Select
    Range("AB2").Select
    ActiveCell.FormulaR1C1 = x
    Range("X15:AE15").Copy
    Sheets("Tabelle1").Select
    Range("A2").Select
    Cells(lastRow + 1, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
    xlNone, SkipBlanks:=False, Transpose:=False

    Next

    For x = 101 To 200

    lastRow = Cells(Rows.Count, 1).End(xlUp).Row

    Sheets("Batch size calcs").Select
    Range("AB2").Select
    ActiveCell.FormulaR1C1 = x
    Range("X15:AE15").Copy
    Sheets("Tabelle2").Select
    Range("A2").Select
    Cells(lastRow + 1, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
    xlNone, SkipBlanks:=False, Transpose:=False
    Next
    Last edited by Mengo85; 01-09-2020 at 05:26 AM.

  2. #2
    Forum Contributor
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2013
    Posts
    131

    Re: Copy Paste loop in multiple tabs

    Do you have an example workbook you could attach? At first glance my thought is that this is the culprit:
    Please Login or Register  to view this content.
    but without a workbook to test on I can't be sure.

  3. #3
    Registered User
    Join Date
    07-06-2010
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Copy Paste loop in multiple tabs

    Hi, mrbusto71,

    thanks for your quick reply. Attached you will find an example workbook. The tab "Batch size calcs" has been changed to "calcs".

    I hope this helps.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-06-2010
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Copy Paste loop in multiple tabs

    anybody?

+ 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] Loop Copy and paste multiple ranges from multiple workbooks
    By Ravenous in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2017, 05:46 PM
  2. [SOLVED] Need VBA to Copy/Paste multiple Different Lines from Data Sheet to Different Tabs
    By Aeneren in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2015, 04:20 PM
  3. [SOLVED] Help with Copy/Paste multiple Different Lines from Data Sheet to Different Tabs
    By Aeneren in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2015, 11:31 AM
  4. Copy paste a particular range of cells As values in multiple tabs
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2013, 10:43 AM
  5. MAcro to copy paste a certain range of cells in multiple tabs as values
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2013, 03:59 AM
  6. Replies: 2
    Last Post: 01-21-2013, 02:26 PM
  7. [SOLVED] Can you copy multiple tabs from formulas to values w/o paste spec?
    By Brent in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-26-2005, 08:05 PM

Tags for this Thread

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