ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying cells... (https://www.excelbanter.com/excel-programming/350515-copying-cells.html)

Sylvia[_17_]

Copying cells...
 

I want to write a macro for copying the cells from file1 to file2. Th
data will be there only in the 2nd row.
The condition is, I want to copy only that perticular cell at th
corresponding cell of other file
For eg. if the data is there at the position "A2" and "A4" in File
then I want to copy this data in the file2 at "A2" and "A4" positio
only.

Thanks,
Sylvi

--
Sylvi
-----------------------------------------------------------------------
Sylvia's Profile: http://www.excelforum.com/member.php...fo&userid=3030
View this thread: http://www.excelforum.com/showthread.php?threadid=50160


Tom Ogilvy

Copying cells...
 
Dim sh1 as Worksheet, sh2 as Worksheet
Dim cell as Range
set sh1 = Workbooks("SourceBook.xls").Worksheets(1)
set sh2 = Workbooks("DestBook.xls").Worksheets(1)
for each cell in Sh1.Range("A2:A50")
if cell.Value = "Copy" then
cell.EntireRow.copy Destination:=sh2.Cells(cell.row,1)
end if
Next

--
Regards,
Tom Ogilvy


"Sylvia" wrote in
message ...

I want to write a macro for copying the cells from file1 to file2. The
data will be there only in the 2nd row.
The condition is, I want to copy only that perticular cell at the
corresponding cell of other file
For eg. if the data is there at the position "A2" and "A4" in File1
then I want to copy this data in the file2 at "A2" and "A4" position
only.

Thanks,
Sylvia


--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile:

http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=501609





All times are GMT +1. The time now is 10:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com