Ranjan, copy this sub and paste it in a regular module. If necessary,
change book2.xls to the actual name of the workbook you want to copy to. If
necessary, change the 1 in Sheets(1) to the number of the sheet you want to
copy to (or you can use the name of the sheet, such as Sheet("MySheet").
Display the sheet you want to copy from and click on it to make it active.
Then run the sub.
HTH,
James
Sub CopyAndPaste()
ActiveSheet.Columns(1).Copy
Destination:=Workbooks("book2.xls").Sheets(1).Range("d1")
ActiveSheet.Columns(2).Copy
Destination:=Workbooks("book2.xls").Sheets(1).Range("f1")
ActiveSheet.Columns(5).Copy
Destination:=Workbooks("book2.xls").Sheets(1).Range("h1")
ActiveSheet.Columns(7).Copy
Destination:=Workbooks("book2.xls").Sheets(1).Range("k1")
End Sub
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Mar 5, 7:05 pm, ranjan.k...@comcast.net wrote:
>
>> Hi,
>
>> I would appreciate any VBA code for the following:
>
>> I need to extract data from say ColumnA, ColumnB, ColumnE and ColumnG
>> from "workbook1"
>> and placed this data in the corresponding columns (ColumnD, ColumnF,
>> ColumnH, and ColumnK) in "workbook2".
> Hi,
> I had posted the following on March 3rd I had gotten a response, but
> unfortunately it not the totally correct. Can someone help out?
>
>> Can you help?
>
>> Thanks Ranjan
>
> Sub CopyWbk
> Dim src, dest
> i=1
> Set src=Workbooks("Workbook1").Sheets("Sheet1")
> Set dest = Workbooks("Workbook1").Sheets("Sheet1")
> While src.Cells(i,1)<>""
> dest.Cells(i,4)=src.Cells(i,1)
> dest.Cells(i,6)=src.Cells(i,2)
> dest.Cells(i,8)=src.Cells(i,5)
> dest.Cells(i,11)=src.Cells(i,7)
> i = i+1
> Wend
> End Sub
>
> HTH
> Kostis Vezerides
>
|