View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
tkraju via OfficeKB.com tkraju via OfficeKB.com is offline
external usenet poster
 
Posts: 109
Default copy data from source file to w/book

Thanks,bou it didn't give me the desired results I need.Your code updated
only sheet1 of my w/book.It has not looped through all sheets of my w/book to
do the same task.My sheet2 and Sheet3 names also exists in "SalesReport.csv"
ColA:A range.Please reread my question carefully.

Tom Ogilvy wrote:
Sub copydata()
Dim sh as Worksheet, sh1 as Worksheet
Dim bk as Workbook, cell as Range
Dim rng1 as Range
set sh = WorkBooks("SalesReport.csv").Worksheets(1)
set rng1 = sh.Range(sh.Cells(2,1),sh.cells(rows.count,1).End( xlup))
set bk = Workbooks("Data.xls")
for each cell in rng1
if cell.offset(0,1).Value = "MB" then
set sh1 = nothing
on Error Resume Next
set sh1 = bk.worksheets(cell.Value)
on Error goto 0
if not sh1 is nothing then
cell.offset(0,2).Resize(1,3).copy _
sh1.cells(rows.count,1).end(xlup)(2)
end if
end if
Next
End Sub

I am looking for code that can do the following task.
I have a downloaded file named "SalesReport.csv" contains source data about

[quoted text clipped - 23 lines]
are to be copied and pasted at row 4 in 'Carol' sheet.Then goto next sheet.
I shall be thankful if anybody helps me .


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200703/1