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: 17
Default How To Copy & PasteSpecial: Range from Mult Wksht into SummarySheet

My workbook contains 100 wource wkshts identical except for contents
of cells. My code adds a new "Summary" wksht where I want to be able
to paste values and numbers only from the same range in each of the
other 100 wkshts in the wkbook. I want to loop thru each sht in the
workbook and:

1) Unprotect the source sht (password is "mbt"), then
2) Select a range ("G256:AD259") in the source sht, then
3) Paste only the cell values and number formats from that range into
the "Summary" wksht starting in cell "c3", then
4) place the name of the source sht in cell "b3", then
4) Go to next source wksht, copy the same range ("G256:AD259), and
paste those cell values and number formats into the next blank row
below what was just pasted, and
6) Continue the process until the copyrange & paste special has looped
thru all of the 100 source wksht.

I have gathered snipets of code that seem to almost work, but the use
of destination cell seems inappropriate for PasteSpecial purposes.
What I want to do is: Go to first source wksht - CopyRange - go to
cell "c3" in "Summary" and PasteValuesAndNumberFormat - place source
the wksht name for that source wksht into cell "b3" of "Summary", and
then loop through all of the remaining worksheets. Can someone correct
my code? TIA

Mike Taylor

---------------------------------------------------------------------------

Sub SummaryWkshtsAll()

Dim sht As Worksheet
Dim SummSht As Worksheet
Dim destCell As Range
Dim CopyRange As Range
Dim iRow As Long
Dim testRange As Range

Set SummSht = ActiveWorkbook.Sheets.Add
SummSht.Name = "0Summary"
Set destCell = SummSht.Range("b4")

For Each sht In ActiveWorkbook.Worksheets
With sht
If .Name < "Summary" Then
If Not IsEmpty(.Range("a256")) Then
Set CopyRange = .Range("g256:ad" & .Cells(259,
"G").End _(xlUp).Row) '.Range("g256", .Range("g256").End(xlDown))

'Set CopyRange = .Range("G256:AD259")
For iRow = 257 To 259
Set testRange = .Range(.Cells(iRow, "G"),
..Cells _(iRow, "AD"))
If Application.CountG(testRange) 0 Then
Set CopyRange = Union(CopyRange, testRange)
End If
Next iRow
'Set testRange = Intersect(CopyRange, .Columns(1))
destCell.Offset(0,
-1).Resize(CopyRange.Cells.Count, _ 1).Value = .Name
CopyRange.Copy Destination:=destCell
Set destCell = SummSht.Cells(SummSht.Rows.Count,
"b").End(xlUp).Offset(1, 0)
End If
End If
End With
Next sht
End Sub
 
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
I want to save a copy of a wksht. but without any of the formulas ms_gebhart Excel Worksheet Functions 5 December 17th 09 06:44 PM
1st 2 rows of wksht show up @ top of each page of the wksht Remote Paralegal Excel Discussion (Misc queries) 2 October 6th 08 07:59 PM
Can I copy page set ups in Excel 2003 from one wksht to another MHacct Excel Worksheet Functions 1 August 9th 07 05:40 PM
VB PasteSpecial when range changes mjwillyone[_2_] Excel Programming 4 December 28th 03 03:31 AM
Copy & PasteSpecial Arthur[_3_] Excel Programming 1 November 3rd 03 06:41 PM


All times are GMT +1. The time now is 02:15 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"