I need to copy a column of data to another column on a different worksheet, pasting values only. The appropriate paste column is identified in a single cell. This cell will be changed manually each time the macro is applied. So one time I might want to copy/paste in the first column, so my identifier cell is 1. The next time I might input 5 in this cell so that I offset 5 columns to the right to copy/paste data. Thank you.
Asked
Active
Viewed 97 times
1 Answers
0
You can reference the columns in a worksheet using the Columns property. You can achieve what I think you're trying to do with code like this.
Dim col As Integer
col = SomeSheet.Cells(1,1).Value
FromSheet.Columns(col).copy
ToSheet.Columns(col).PasteSpecial xlPasteValues

Nicholas Hunter
- 1,791
- 1
- 11
- 14
-
Thank you for this answer. Can I use a reference in Cells such as Cells(A6,1)? – Michael Price Apr 01 '21 at 22:07