Importing a file..then saving back to original file

H

HarveyM.

I hope I can explain this corretly. I have an employee work schedule file.
There is also an absence file needed separately for Union quarterly
review purposes. I would like to have a macro that will import the file into
the schedule for updating and then save the sheets back as a named file from
a cell
within a sheet "3rd Qtr", "4th Qtr", etc. depending on a cell content.
The imported file will have a "FacePage" and the rest will be numbered sheets
1,2,3,4,5,6,7 etc that correspond to an employee listed on the "FacePage".
I need the file separate because of the quarterly distribution..the schedule
is year round and the absence file must be broken up into quarters for review.
 
G

GB

Think that more information is needed to help.

Think to get good assistance, would need to know how many workbooks are
involved, the tabs (worksheets) for each workbook, the type of data contained
in the tabs (i.e., more information like the face page description, that the
face page contains rows of data applicable to an employee to reference the
correct tab within the workbook. Don't know which workbook, but at least
that part seems to make sense.), where your dates are located (i.e., on
worksheet X of workbook Y next to employee information), and what is needed
to be "updated".

What I can see is that you need to take the data from one file, as you move
through each line, you figure out the matching tab for that user based on
information stored in the FacePage, copy the data, then after all data has
been copied, sort/search/select data applicable to a particular qtr, copy
that data to a new tab including headers to a new worksheet, store that new
worksheet as a quarterly file.

As for entering 3rd Qtr, 4th Qtr, etc. If you are typing that information
in, then you are doing more work than you need to. A macro could be setup,
if that data really needs to be presented, that would show the applicable qtr
as a result of the date range. It may be as simple as an equation in excel.

If (month(Range("A" & "1")) <= 3, "1st CY Qtr", if(Month(Range("A" & "1"))
<=6, "2nd CY Qtr",if (month(Range("A" & "1")) <= 9, "3rd CY Qtr", "4th CY
Qtr")))

Would need to change the text result if the Qtrs are FY but keep the same
numeric sequence of 3, 6, 9, and all other cases (<=12). I.e., <=3 "2nd",
<=6 "3rd", <=9 "4th", <=12 "1st". This of course assumes that the date in
question is in cell A1. For multiple users you would replace the "1" portion
with the row number in question. So if a variable CurRow is your long data
type indicating the current row, it would look like "A" & CurRow.

The other side of it is that you would need to consider the format of your
two workbooks/the multiple worksheets. If the columns of your first
worksheet are not in the same sequence as the destination worksheet, you
would need to account for that in some regards. I typically capture all the
columns of the range in question in an array, and then when I want to copy an
entire row from one place to the other, I use my declared column header data
to ensure that I get the information from the right place to the right place.
The remaining caveat here is that the text of the column header must be
equivalent in both cells, otherwise there is no match. If the source column
is not in the destination worksheet, then I create the column, insert the new
data, and then update the destination file to reflect that no data was
imported for rows that have not received data because it was not present to
copy. And for columns that previously existed but no data was present to
import for the new row I also mark them to indicate that no data was
imported.

Just tried to reread your question, and you talk about importing one file
into another, please indicate which file is to go into which. If you break
up your problem and desired action into smaller chunks then you can tackle
each portion separately with the big picture in mind of getting the desired
result(s). Sometimes you will run across a few ways to accomplish the same
task, and have to determine which is fastest, easiest, and/or most flexible.
Reuse of code makes future development/modification a lot easier.

Sorry couldn't give a complete answer, but I think if you give more info you
might be able to get some "real" assistance. :)
 

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