View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Copy a spreadsheet depeding on a variable

Sub addsheet()
Dim Day As Range, rng As Range
Dim sh As Worksheet

Sheets("SUMMARY").Select
Range("B3").Select

For Each Day In Sheets("SUMMARY").Range("B3:B33")

Set sh = Worksheets(Day.Value)
Set rng = Sheets("Hourly View").Range("A1:Z48")

If Day.Offset(0, 1) = "Conflict" Then
Worksheets.Add After:=Worksheets(worksheets.count)
rng.copy Destination:=Activesheet.Range("A1')
Activesheet.name = Day.value
End If

Next Day

End Sub

would be me guess.

--
Regards,
Tom Ogilvy


"oakman" wrote:


Hello Tom,

Thank you for the response. Pivot Tables are a good suggestion, but
that is exactly what the previous existance of this report was based
on. I am actually trying to create an alternative to Pivot Tables in
the new format. While Pivoting is efficient, the raw data that I have
does not lend it self to making Pivoting an efficient process. I have
tried to come up with some code, so far I can get to the point where a
sheet is added triggered by the word "Conflict" in my "SUMMARY" sheet.
However, I get an error when I tell it to copy the desired range. Can
you take a look at my code and make some suggestions please? Your help
is very much appreciated.
Sub addsheet()
Dim Day As Range, rng As Range
Dim sh As Worksheet

Sheets("SUMMARY").Select
Range("B3").Select

For Each Day In Sheets("SUMMARY").Range("B3:B33")

Set sh = Worksheets(Day.Value)
Set rng = Sheets("Hourly View").Range("A1:Z48")

If Day.Offset(0, 1) = "Conflict" Then
Worksheets.Add.Copy rng
End If

Next Day

End Sub


--
oakman
------------------------------------------------------------------------
oakman's Profile: http://www.excelforum.com/member.php...fo&userid=9172
View this thread: http://www.excelforum.com/showthread...hreadid=567011