PC Review


Reply
Thread Tools Rate Thread

adding rows during copy???

 
 
=?Utf-8?B?Um9taW5hbGw=?=
Guest
Posts: n/a
 
      19th Mar 2007
Okay, don't know if this is possible. Don't know how much of this you'll need
but I'm trying to make this the short story.

I have a text file that I currently copy into a master workbook. I have if
statements to compare 4 identifiers (col. a-d). If all 4 match then it
copies the new stuff into the remaining weeks. The users would like to
combine some stuff and only show a sub-total for one of the identifiers. Can
I total these up during the copy process?

SAMPLE RAW DATA
Jon Doe.....A1....B1....C1....Wk1...Wk2...etc
Jon Doe.....A1....B1....C2....Wk1...Wk2...etc
Jon Doe.....A1....B1....C3....Wk1...Wk2...etc
Jon Doe.....A1....B1....C4....Wk1...Wk2...etc
Jon Doe.....A1....B2....C1....Wk1...Wk2...etc
Jon Doe.....A1....B2....C2....Wk1...Wk2...etc

Now I only need the sub-total for all B1s, I still need the details for B2s.

EXAMPLE CLEANED DATA
Jon Doe.....A1....B1....C....SumWk1...SumWk2...etc
Jon Doe.....A1....B2....C1....Wk1...Wk2...etc.
Jon Doe.....A1....B2....C2....Wk1...Wk2...etc.

Someone suggested using an array but I'm not very familiar with them.

Am I stuck copying to the master and then doing a sub-total?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      20th Mar 2007
Yes it is possible to do during the read operation, but it is not
recommended. the problem is when you find a B1 then you have to search the
remaining part of the file for the matching data in columns A-D. Then you
have to rewind the open file and get back to the same line that you started
with.

Using Arrays basically means to read the data into memory before pasting the
file into the spreadsheet. Again for large files you end up using a lot of
memory in the computer.

The best way is to create a temporary spreadsheet to read the data into.
then extract the data from the temporary spreadsheet to the master worksheet
and then clear the temporary worksheet.

Using the temporary will make debugging the code easier than the other two
approaches (rewinding file, or using arrarys).

I would use a cleaver trick in extracting the lines from the temporary sheet
by using an extra column. Every time you extract a line from the temporary
sheet add a one to the new column. You algorithm would look something like
this


for each row in temporary

if B1 row to master sheet

else B2
if not 1 in new column
get sutotals from present row
for current row to last row
If columns A-D match
Add values to subtotals
enter 1 in new column
end if
Next row
end if
end if
next row


"Rominall" wrote:

> Okay, don't know if this is possible. Don't know how much of this you'll need
> but I'm trying to make this the short story.
>
> I have a text file that I currently copy into a master workbook. I have if
> statements to compare 4 identifiers (col. a-d). If all 4 match then it
> copies the new stuff into the remaining weeks. The users would like to
> combine some stuff and only show a sub-total for one of the identifiers. Can
> I total these up during the copy process?
>
> SAMPLE RAW DATA
> Jon Doe.....A1....B1....C1....Wk1...Wk2...etc
> Jon Doe.....A1....B1....C2....Wk1...Wk2...etc
> Jon Doe.....A1....B1....C3....Wk1...Wk2...etc
> Jon Doe.....A1....B1....C4....Wk1...Wk2...etc
> Jon Doe.....A1....B2....C1....Wk1...Wk2...etc
> Jon Doe.....A1....B2....C2....Wk1...Wk2...etc
>
> Now I only need the sub-total for all B1s, I still need the details for B2s.
>
> EXAMPLE CLEANED DATA
> Jon Doe.....A1....B1....C....SumWk1...SumWk2...etc
> Jon Doe.....A1....B2....C1....Wk1...Wk2...etc.
> Jon Doe.....A1....B2....C2....Wk1...Wk2...etc.
>
> Someone suggested using an array but I'm not very familiar with them.
>
> Am I stuck copying to the master and then doing a sub-total?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding some rows in the middle of adding some other rows =?Utf-8?B?SmFuaXM=?= Microsoft Excel Programming 3 4th Oct 2007 03:20 AM
Adding rows and copy/paste through a user form DuncanL Microsoft Excel Programming 0 15th Aug 2007 12:24 PM
Adding rows to a data table: Rows do not show up =?Utf-8?B?dnZlbms=?= Microsoft VB .NET 2 10th Oct 2006 12:07 AM
Adding Rows offsets to working rows across two worksheets =?Utf-8?B?VG9t?= Microsoft Excel Setup 3 30th Jul 2006 07:54 PM
How to prevent drawing DataGrid rows while adding rows? =?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?= Microsoft C# .NET 2 6th Apr 2005 04:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:18 AM.