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: 50
Default Copy range on multiple sheets into one sheet

Hello,
I have a summary sheet that up until this morning worked just great. It
deleted the current sheet, added another, and transferred all the data.
Somebody other than me will be using it now though, and I'd like to make it a
little more user friendly. I have the coding except for the part where it
loops through and picks the data up. Below is the first part of the coding
from when it deleted the worksheet. How can I modify that to just grab the
data and put it on there? I appreciate any help.

Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
Dim CopyRng As Range

Application.ScreenUpdating = False
Application.EnableEvents = False

'Delete the sheet "Exceptions" if it exists
Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets("Exceptions").Delete
On Error GoTo 0
Application.DisplayAlerts = True

'Add a worksheet with the name "Exceptions"
Set DestSh = ActiveWorkbook.Worksheets.Add
DestSh.Name = "Exceptions"

'loop through all worksheets and copy the data to the DestSh
For Each sh In ActiveWorkbook.Worksheets
If sh.Name < DestSh.Name Then

'Find the last row with data on the DestSh
Last = LastRow(DestSh)

'Fill in the range that you want to copy
Set CopyRng = sh.Range("L11:V93")

'Test if there enough rows in the DestSh to copy all the data
If Last + CopyRng.Rows.Count DestSh.Rows.Count Then
MsgBox "There are not enough rows in the Destsh"
GoTo ExitTheSub
End If

'This copies all values/formats

With CopyRng
DestSh.Cells(Last + 1, "A").Resize(.Rows.Count, _
.Columns.Count).Value = .Value
End With

End If
Next

ExitTheSub:

Application.GoTo DestSh.Cells(1)

'AutoFit the column width in the DestSh sheet
DestSh.Columns.AutoFit

Application.EnableEvents = True

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1

 
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
Copy range on multiple sheets into one sheet Joe_Hunt via OfficeKB.com Excel Programming 8 June 1st 09 04:07 PM
Conditional copy from multiple sheets to one sheet Pam[_3_] Excel Programming 2 April 30th 09 06:23 PM
Conditionally copy from multiple sheets to one sheet Pam[_3_] Excel Programming 2 April 29th 09 10:30 PM
Copy data from multiple sheets into new sheet Angie Excel Worksheet Functions 0 June 5th 07 10:53 PM
How do I copy setting from one sheet to multiple sheets in Excel? danam6 Excel Discussion (Misc queries) 1 April 27th 06 09:05 AM


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