Results 1 to 2 of 2

Loop through worksheets and copy data ranges into one sheet

Threaded View

  1. #1
    Registered User
    Join Date
    02-19-2013
    Location
    Miqmi
    MS-Off Ver
    Excel 2007
    Posts
    2

    Loop through worksheets and copy data ranges into one sheet

    Hi Everyone,

    I had a the following code that loops through rows of data until it finds a row with values of 0. Then it selects the rightmost
    cell of that row that has a non-zero value and selects a range from cell A15 to that rightmost cell:

    Sub copy_combine_()
    
    Dim i As Long, M As Long
    Dim xlastrow As Integer
    Dim rng As Range
    Dim xrow As Integer
    
    
    N = Sheets.Count - 1
    M = 2
      For i = 1 To N
        lastrow = ThisWorkbook.ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
        xrow = 15
        Range("b10000").End(xlUp).Select
        xlastrow = ActiveCell.Row
    Do Until Cells(xrow, 2).Value = "0"
                If Cells(xrow, 2).Value <> "0" Then
                Cells(xrow, 2).Select
    
                End If
    xrow = xrow + 1
    
    Loop
       
    ActiveCell.Select
    Selection.Offset(0, 2).Select
    Range(ActiveCell, "A15").Copy
    Sheets("Q1 Breakdown").Activate
    Range("a10000").End(xlUp).PasteSpecial xlPasteValues
    
    Next i
    The issue I'm having is that when I run the macro the sheets never changes. I want the code to copy the range i defined with the loo code,
    paste it to the last sheet in the workbook then go to the second sheet and do the same until it grabs data from all sheets but the last one.
    What am I doing wrong
    Last edited by alansidman; 09-03-2015 at 04:44 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 05-20-2014, 10:44 AM
  2. [SOLVED] Loop through worksheets to copy data to new workbook
    By livelyzd in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-23-2013, 04:44 AM
  3. loop to copy/paste data between worksheets, save results
    By nbmg1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2013, 06:18 PM
  4. Replies: 2
    Last Post: 07-17-2012, 09:18 PM
  5. Looping through Worksheets, Copy/Paste Each Sheet during Loop
    By eduardito in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2012, 07:01 AM
  6. Do While Loop Q: Copying sheet data ranges to another sheet's ranges
    By foolios in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-30-2011, 05:05 PM
  7. Loop command macro to copy data between worksheets
    By ThunderBuck in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-12-2009, 11:55 AM

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