From: bryen on
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.



From: joel on

I won't write the entire solution. Ihave poste code like this plenty of
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 with


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=179210

[url="http://www.thecodecage.com"]Microsoft Office Help[/url]