PC Review


Reply
Thread Tools Rate Thread

Copying specific cell ranges from a worksheet multiple times to a newsheet

 
 
Kris Winntech
Guest
Posts: n/a
 
      9th Nov 2009
Here is what I have:

I have a workbook with multiple worksheets. Each worksheet corresponds to a certain store fixture estimate. Ont these sheets I have a specific cell where you can input how many fixtures of that type are to be used.

On that sheet also, is a range of cells (ex. Range("A65:F3340")) that needs to be copied to a new summations sheet of total hours to build the project.

If sheet 1 has 1 fixture - the macro should copy the range of cells only once.
Sheet 2 has 4 fixtures - tha macro should copy the same range four times appending each set of data tot eh end of the previous, And so on for each fixture sheet.

How would I write a macro to do this? I can provide a sample workbook if needed. Thanks.

EggHeadCafe - Software Developer Portal of Choice
VIsual Studio.NET 2005 ClickOnce Technology: An Overview
http://www.eggheadcafe.com/tutorials...t-2005-cl.aspx
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      9th Nov 2009
This assumes that the range containing the items is A2:A20. You can change
that to the actual range. Also change the sheet names to the actual sheets
used.

Sub GetBOM()
Dim rng As Range, sh1 As Worksheet, sh2 As Worksheet
Set sh1 = ActiveSheet
Set sh2 = Sheets("Sheet2") 'Change as required
Set rng = sh1.Range("A2:A20")
mult = Application.InputBox("Enter the quantity of fixtures", _
"FIXTURE QTY", Type:=1)
For i = 1 To mult
x = sh2.Cells(Rows.Count, 1).End(xlUp).Offset(2).Address
rng.Copy sh2.Range(x)
Next
End Sub




<Kris Winntech> wrote in message news:(E-Mail Removed)...
> Here is what I have:
>
> I have a workbook with multiple worksheets. Each worksheet corresponds to
> a certain store fixture estimate. Ont these sheets I have a specific cell
> where you can input how many fixtures of that type are to be used.
>
> On that sheet also, is a range of cells (ex. Range("A65:F3340")) that
> needs to be copied to a new summations sheet of total hours to build the
> project.
>
> If sheet 1 has 1 fixture - the macro should copy the range of cells only
> once.
> Sheet 2 has 4 fixtures - tha macro should copy the same range four times
> appending each set of data tot eh end of the previous, And so on for each
> fixture sheet.
>
> How would I write a macro to do this? I can provide a sample workbook if
> needed. Thanks.
>
> EggHeadCafe - Software Developer Portal of Choice
> VIsual Studio.NET 2005 ClickOnce Technology: An Overview
> http://www.eggheadcafe.com/tutorials...t-2005-cl.aspx



 
Reply With Quote
 
Kris Winntech
Guest
Posts: n/a
 
      9th Nov 2009
How would I loop this to make it work for all sheets in the workbook?



JLGWhiz wrote:

This assumes that the range containing the items is A2:A20.
09-Nov-09

This assumes that the range containing the items is A2:A20. You can chang
that to the actual range. Also change the sheet names to the actual sheet
used

Sub GetBOM(
Dim rng As Range, sh1 As Worksheet, sh2 As Workshee
Set sh1 = ActiveShee
Set sh2 = Sheets("Sheet2") 'Change as require
Set rng = sh1.Range("A2:A20"
mult = Application.InputBox("Enter the quantity of fixtures",
"FIXTURE QTY", Type:=1
For i = 1 To mul
x = sh2.Cells(Rows.Count, 1).End(xlUp).Offset(2).Addres
rng.Copy sh2.Range(x
Nex
End Sub

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
Working with Client Side Xml Data Islands from Server-Side ASP.NET code
http://www.eggheadcafe.com/tutorials...ient-side.aspx
 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      10th Nov 2009

If there is a constant cell on each sheet that
indicates the number of fixtures for that sheet,
you could also eliminate the input box by making
mult = that cell value. Otherwise you are stuck
with the input box. I did not test this revision,
but it should go through all the sheets in the
active workbook. Again, change sheet names and range
references to actual.

Sub GetBOM()
Dim rng As Range, sh1 As Worksheet, sh2 As Worksheet
For Each sh1 In ThisWorkbook.Sheets
If sh1.Name <> "Sheet2" 'To ignore if is summation sheet
Set sh2 = Sheets("Sheet2") 'Change as required
Set rng = sh1.Range("A2:A20")
mult = Application.InputBox("Enter the quantity of fixtures", _
"FIXTURE QTY", Type:=1)
For i = 1 To mult
x = sh2.Cells(Rows.Count, 1).End(xlUp).Offset(2).Address
rng.Copy sh2.Range(x)
Next
End If
Next
End Sub



<Kris Winntech> wrote in message news:(E-Mail Removed)...
> How would I loop this to make it work for all sheets in the workbook?
>
>
>
> JLGWhiz wrote:
>
> This assumes that the range containing the items is A2:A20.
> 09-Nov-09
>
> This assumes that the range containing the items is A2:A20. You can
> change
> that to the actual range. Also change the sheet names to the actual
> sheets
> used.
>
> Sub GetBOM()
> Dim rng As Range, sh1 As Worksheet, sh2 As Worksheet
> Set sh1 = ActiveSheet
> Set sh2 = Sheets("Sheet2") 'Change as required
> Set rng = sh1.Range("A2:A20")
> mult = Application.InputBox("Enter the quantity of fixtures", _
> "FIXTURE QTY", Type:=1)
> For i = 1 To mult
> x = sh2.Cells(Rows.Count, 1).End(xlUp).Offset(2).Address
> rng.Copy sh2.Range(x)
> Next
> End Sub
>
> Previous Posts In This Thread:
>
> EggHeadCafe - Software Developer Portal of Choice
> Working with Client Side Xml Data Islands from Server-Side ASP.NET code
> http://www.eggheadcafe.com/tutorials...ient-side.aspx



 
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
Copying Cell from Multiple Worksheets to a Summary Worksheet shel Microsoft Excel Worksheet Functions 4 14th Jan 2009 08:03 PM
How do I force entry in multiple cell ranges in one worksheet CindyB Microsoft Excel Worksheet Functions 0 10th Jul 2008 06:08 PM
Protection - multiple ranges at different times PurpleMilk Microsoft Excel Worksheet Functions 0 13th May 2008 12:05 AM
copying cell info from one worksheet to another based on a specific date VishalHPatel@gmail.com Microsoft Excel Programming 8 16th Nov 2006 03:31 PM
How to send specific cell ranges to multiple e-mail addresses =?Utf-8?B?TWVnaGFu?= Microsoft Excel Programming 0 16th Oct 2006 06:14 PM


Features
 

Advertising
 

Newsgroups
 


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