![]() |
Copy in a range
Hello,
I'm trying to do a macro VBA for that: There is a range in a sheet that I don't know how many rows it has. I want to copy cells from column D to column C (for example), but only in the range, becouse there's another data in this D and C columns out of the range. Can anybody help me? Thank you very much. |
Copy in a range
Hi,
I'm not sure I completely understand but I think you mean you have date in column D then a gap then more data and you only want to copy the first portion of the data and this may help. Sub prime() lastrow = Range("D1").End(xlDown).Row Set myrange = Range("D1:D" & lastrow) For Each c In myrange c.Offset(, -1).Value = c.Value Next End Sub Right click you sheet tab, view code and psate this in. Mike "moixerno" wrote: Hello, I'm trying to do a macro VBA for that: There is a range in a sheet that I don't know how many rows it has. I want to copy cells from column D to column C (for example), but only in the range, becouse there's another data in this D and C columns out of the range. Can anybody help me? Thank you very much. |
Copy in a range
Thanks Mike. It works very well.
Moixerno "Mike H" wrote: Hi, I'm not sure I completely understand but I think you mean you have date in column D then a gap then more data and you only want to copy the first portion of the data and this may help. Sub prime() lastrow = Range("D1").End(xlDown).Row Set myrange = Range("D1:D" & lastrow) For Each c In myrange c.Offset(, -1).Value = c.Value Next End Sub Right click you sheet tab, view code and psate this in. Mike "moixerno" wrote: Hello, I'm trying to do a macro VBA for that: There is a range in a sheet that I don't know how many rows it has. I want to copy cells from column D to column C (for example), but only in the range, becouse there's another data in this D and C columns out of the range. Can anybody help me? Thank you very much. |
All times are GMT +1. The time now is 11:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com