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
Bookmarks