Copy the row and paste in a sheet w/ new col

Closed
Josh - Apr 18, 2012 at 11:41 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 20, 2012 at 09:53 AM
Hello,

I am using Excel 2007.

I am trying to figure out how to copy a row from one worksheet (in workbookA) and paste to a new row in a different workbook (workbookB), but in workbookB, there is another column added at the beginning with the value pulled from Sheet1 (workbookA) in A15. Here is what I am using so far. I just need to know how to get it to populate Column A with the value in A15.

e = 1
k = 2

Do Until IsEmpty(OldSheet.Range("I" & k))
e = e + 1
DbWb.Sheets("Sheet1").Rows(e + lNextRow - 2).Value = OldSheet.Rows(k).Value
k = k + 1
Loop

Any assistance would be greatly appreciated.

Thank you,
Josh

Related:

1 response

Ok. What I did is just write the value to the end of the row, in a new columnn, instead of trying to place it in front of the row. However, I'd still like to know how to do what I had originally asked.

Thank you,
Josh
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Apr 19, 2012 at 04:29 PM
What you mean by populate column A with value from A15.
If I got it correct, it seems to me you are copying data from one sheet to another sheet. Once that data is copied, you want column A to be populated with what ever the value was in cell A15 in sheet 1. Is that so ?
Other thing is that it seems to me you are copying one row at a time . Any reason ? why not copy all in one go ?
0
rizvisa1:
Yes, I am copying info from one sheet to another. However, I am doing this for about 30 other worksheets, which go to the same sheet in dbwb, and I didn't want there to be blank lines.
Thank you,
Josh
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Apr 20, 2012 at 09:53 AM
Josh, one row at a time is not too efficient way. If blank rows are issue there are two approaches that you may want to consider.
1. Filter the source sheet for non blank rows and then copy and paste visible rows
2. Copy all rows and paste. Then filter on blanks rows and then delete them

having said that it seems to me that perhaps all these sheet do not have in-between any blank rows. All you want to do is copy the data from all these sheets into a new sheet in a continuous manner. In that case, you only copy the data and any thing more
0