Hi,
I am facing an issue trying to copy columns from one existing excel sheet (say Sheet1.xlsm) to a new dynamically created one (say Sheet2.xls).
Scenario:
Sheet1 has colums A thru AK of which I need to selectively copy some columns into Sheet2
Code for this functionality:
wks- reference to Sheet2/new sheet
ws- reference to Sheet1/old sheet
---------------------------
irow = 2
LastRow = 1
For irow = 2 To totalRows Step 1
wks.Cells(LastRow, "X").Value = ws.Cells(irow, col_custNum).Value
LastRow = LastRow + 1
Next irow
---------------------------
Here, though I specify the destination column as 'X' it always pastes code to column 'M'. There is an offset of about 10 columns for every column I try to paste into the new sheet. I tried creating an intermediate sheet and copying data from that however this issue still persists. The wierd part is untill a few days back it was offesetting the by about 7 columns, so I tweaked the code accordingly. However, now it is offsetting it by 10 columns and I cannot keep changing the code. Any pointers as to why this is happening and some solution will be very helpful.
Thanks,
Prajakta
I am facing an issue trying to copy columns from one existing excel sheet (say Sheet1.xlsm) to a new dynamically created one (say Sheet2.xls).
Scenario:
Sheet1 has colums A thru AK of which I need to selectively copy some columns into Sheet2
Code for this functionality:
wks- reference to Sheet2/new sheet
ws- reference to Sheet1/old sheet
---------------------------
irow = 2
LastRow = 1
For irow = 2 To totalRows Step 1
wks.Cells(LastRow, "X").Value = ws.Cells(irow, col_custNum).Value
LastRow = LastRow + 1
Next irow
---------------------------
Here, though I specify the destination column as 'X' it always pastes code to column 'M'. There is an offset of about 10 columns for every column I try to paste into the new sheet. I tried creating an intermediate sheet and copying data from that however this issue still persists. The wierd part is untill a few days back it was offesetting the by about 7 columns, so I tweaked the code accordingly. However, now it is offsetting it by 10 columns and I cannot keep changing the code. Any pointers as to why this is happening and some solution will be very helpful.
Thanks,
Prajakta