LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying rows of data based on a value in a cell.

First of all, apologies for using a fake email addy. Just trying to ward off
the spammers...

A little background on what I'm trying to do. Every year, we print out
labels for boxes that are part of a food basket charity that donates boxes
of food and supplies to low-income people so they can have something for
Christmas. The issue is that the customer wants a label for each box, saying
box 1 of 4, box 2 of 4, and so on. In the excel file there is only one line
with the person's name, address and how many boxes the person is to receive.
In order to create a label for each box, I have to insert a blank line for
each box, and then fill down the data from the first line so I have a
duplicate record for each box, then fill in a series to get 1, 2, 3, and so
on. It's a cumbersome process and there are 330 families, for a total of
1770 boxes.

What I am trying to do is to create a macro that when I select a single cell
that is on the row of each family, it would do the process I described
above, by reading the column that contains how many boxes a family is to
receive. I did a macro recording to get an idea. Here's a sample for a
family that is to receive 4 boxes:

Sub OFBSetup()
Rows("1:1").Select
Selection.Insert Shift:=xlUp
Selection.Insert Shift:=xlUp
Selection.Insert Shift:=xlUp
Rows("4:4").Select
Selection.AutoFill Destination:=Rows("1:4"), Type:=xlFillCopy
Rows("1:4").Select
Range("E1").Select
Selection.AutoFill Destination:=Range("E1:E4"), Type:=xlFillSeries
Range("E1:E4").Select
End Sub

I have an idea how to make it work, where I would select the first cell in a
row that I want to expand, then execute the macro-which is to read the value
in column F, which is the number of boxes total, subtract one, then do a
loop where a row would be inserted below the original row, copy the data
from the original row, then increment the value in Column E by 1 in the
newly copied row. The loop will repeat until the value in column E - 1 is
reached.

To clarify, If I select a cell of a row where the value in Column F is "4",
the macro will insert 3 rows, copy down all the values of the entire row
into the blank rows, and do a series fill down into each row of Column E, so
each successive row will read 1, 2, 3, 4.

I hope this helps anyone understand what I want to do. I do have a basic
understanding of programming, but I'm totally new at creating macros for
Excel and am not knowledgeable on the syntax needed to accomplish what I'm
trying to do. I need to have this macro working by Wednesday afternoon since
we have to have the labels printed by Thursday. If I did it manually, it
would have taken me all day to do it, and the macro would be a great
timesaver.

Thanks for your help!!!


--
Rcoaster, of the rochester.rr.com domain.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying whole lines based on one cell Hankjam[_2_] Excel Discussion (Misc queries) 1 February 23rd 08 05:34 PM
Copying rows from 2 sheets to a new worksheet based on date criter Phill_Morgan Excel Discussion (Misc queries) 9 August 29th 07 08:03 AM
need help please inserting multiple rows based on cell value then copying to data sheet [email protected] Excel Worksheet Functions 1 July 1st 07 08:44 PM
Copying data based on a condition aheintz57 Excel Worksheet Functions 4 October 9th 06 05:12 AM
Copying whole rows based upon one criteria kirbster1973 Excel Discussion (Misc queries) 2 May 26th 05 10:00 PM


All times are GMT +1. The time now is 08:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"