I want to copy all rows and columns from various sheets and paste in an one worksheet one below the other .
But I am getting error . I tried using various example provided by the site . But none is working for me . Could please help me in resolving . I passing the worksheets in array .So I will get sheets in order.
I provided code where I am getting error . I am getting error in the pasting section . It is sayings that it should be either A1 or R1C1 . But I need to paste all sheets one below the another in one sheet.
For m = 1 To fnum
lastrow = tempws.Range("A" & ws.Rows.Count).End(xlUp).Row
ws(m).Cells.Copy tempws.Cells((lastrow + 1), 1)
Next m
tempws.Save
It’s because you are trying to copy the ENTIRE range of cells of a worksheet into a section that is less than an entire sheet, on the main sheet. It won’t work, because there aren’t enough cells left. You need to size down your copy sheet to only capture the cells with data.
Something like this should be a good framework to get you started. You may need to tweak things to fit your data. Also, this assumes that all the data in your copy sheets starts from cell A1. Again, adjust if needed.
Also, if you are getting a reference error due to A1 or R1C1 notation, you may want to just paste as values, instead of a straight copy / paste.