![]() |
Add data to sheet, in next available column.
Hello.
I am trying to alter the following code to get what I want. What I want is: 1) Copy all values/data from sheet "errors" and paste on "data_sum" 2)Copy all data from sheet "corrects" and paste on "data_sum" on the next available row (where the data from sheet "errors" ended, and column A is empty). Sub CopyData() Dim va s Variant, i as Long, sh as worksheet Dim rng as Range, rng1 as Range dim sh1 as Worksheet v = Array("Monday","Tuesday","Wednesday","Thursday","F riday","Saturday") for i = lbound(v) to ubound(v) set sh = worksheets(v(i)) Next set sh1 = Worksheets("shorter") sh1.Cells.Clearcontents for i = lbound(v) to ubound(v) set sh = worksheets(v(i)) set rng = sh.Range("A1").currentRegion set rng1 = sh1.Cells(rows.count,1).End(xlup) if not isempty(rng1) then set rng1 = rng1(2) rng.copy rng1.Pastespecial xlValues next |
Add data to sheet, in next available column.
Sub CopyData()
Dim Lrow As Long Worksheets("errors").UsedRange.Copy Worksheets("data_sum").Range("A1") Lrow = Worksheets("data_sum").Cells(Rows.Count, 1).End(xlUp).Row + 1 Worksheets("corrects").UsedRange.Copy Worksheets("data_sum").Range("A" & Lrow) End Sub Mike F "J.W. Aldridge" wrote in message ups.com... Hello. I am trying to alter the following code to get what I want. What I want is: 1) Copy all values/data from sheet "errors" and paste on "data_sum" 2)Copy all data from sheet "corrects" and paste on "data_sum" on the next available row (where the data from sheet "errors" ended, and column A is empty). Sub CopyData() Dim va s Variant, i as Long, sh as worksheet Dim rng as Range, rng1 as Range dim sh1 as Worksheet v = Array("Monday","Tuesday","Wednesday","Thursday","F riday","Saturday") for i = lbound(v) to ubound(v) set sh = worksheets(v(i)) Next set sh1 = Worksheets("shorter") sh1.Cells.Clearcontents for i = lbound(v) to ubound(v) set sh = worksheets(v(i)) set rng = sh.Range("A1").currentRegion set rng1 = sh1.Cells(rows.count,1).End(xlup) if not isempty(rng1) then set rng1 = rng1(2) rng.copy rng1.Pastespecial xlValues next |
All times are GMT +1. The time now is 04:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com