Transfering Data From One Workbook to Another.

B

bryen

Dear All,
I'm still teaching myself VBA, and there's a huge problem whose
solution i cannot figure out. Your help would be greatly appreciated.
i have an input workbook from which to extract data to another
workbook (thus 2 different workbooks. The input sheet has data split
up in five categories. Each category has five rows of data. So say
the
categories are titled: A, B, C, D, and E in column A. With each
category separated by five rows, each row (in column C) has different
numbers. The output sheet (in the other workbook) has all categories
A, B, C, D, and E arranged (not alphabetically) in separate rows
(column 1), with each category separated by five empty rows. The
solution i desperately need is for a macro to input data within their
matching category in the input sheet. I think this means that it has
to check that the category within the input sheet matches that in the
output sheet, so that it can place that categories data in the right
category's columns. again, your help will be highly appreciated.
 
J

joel

I won't write the entire solution. Ihave poste code like this plenty o
time but will explain the process


Set SourceSht = workbooks("book1.xls")
Set DestSht = workbooks("book2.xls")


with Sourcesht
for colcount = 1 to 5
HeaderName = .Cells(1,ColCount)

with DestSht

set c = .rows(1).find)what:=HeaderName, _
lookin:=xlvalues,lookat:xlwhole)
if c is nothing then
msgbox("Cannot find Header : " & HeaderName)
else
'c.column is the matching column in the destination sheet
end if
end with
next colcount
end wit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top