Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy range on multiple sheets into one sheet

Hi Joe

I am not sure what you want
Do you want to copy the data on the Exceptions sheet below the data that is already on that sheet ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Joe_Hunt via OfficeKB.com" <u45578@uwe wrote in message news:96d0ee6cb37f5@uwe...
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Copy range on multiple sheets into one sheet

Sorry, I'm sometimes not very good at explaining. things. I'd like to copy
the data from cells L11:V93 from every other worksheet in the workbook into
the Exceptions sheet. I can manipulate it from there. I appreciate your help.

Ron de Bruin wrote:
Hi Joe

I am not sure what you want
Do you want to copy the data on the Exceptions sheet below the data that is already on that sheet ?

Hello,
I have a summary sheet that up until this morning worked just great. It

[quoted text clipped - 58 lines]

Application.EnableEvents = True


--
Message posted via http://www.officekb.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy range on multiple sheets into one sheet

Is this not working for you then ?
http://www.rondebruin.nl/copy2.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Joe_Hunt via OfficeKB.com" <u45578@uwe wrote in message news:96d127c2134f8@uwe...
Sorry, I'm sometimes not very good at explaining. things. I'd like to copy
the data from cells L11:V93 from every other worksheet in the workbook into
the Exceptions sheet. I can manipulate it from there. I appreciate your help.

Ron de Bruin wrote:
Hi Joe

I am not sure what you want
Do you want to copy the data on the Exceptions sheet below the data that is already on that sheet ?

Hello,
I have a summary sheet that up until this morning worked just great. It

[quoted text clipped - 58 lines]

Application.EnableEvents = True


--
Message posted via http://www.officekb.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Copy range on multiple sheets into one sheet

Looks a lot like what I have. I took some coding from another workbook and
modified it, so maybe your site is where it originated (I think I have a book
at home with an author by your name. Is that you?). After this though the
worksheet is manipulated to gather the information into a coherent form, and
some calculations are done with it. I'd like this process to be kicked off by
changing a percentage in a specified cell (all that begins in the next set of
instructions), and to make that work I need to gather this information
without deleting the sheet, I guess, by having a change event in the coding
of the worksheet. My thought was just to clear the information existing in
the worksheet and then gathering what I needed from the other worksheets. I
was trying not to make my original post too long.

Ron de Bruin wrote:
Is this not working for you then ?
http://www.rondebruin.nl/copy2.htm

Sorry, I'm sometimes not very good at explaining. things. I'd like to copy
the data from cells L11:V93 from every other worksheet in the workbook into

[quoted text clipped - 10 lines]

Application.EnableEvents = True


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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy range on multiple sheets into one sheet

No Book from me but maybe you seen my article on MSDN

I will reply tomorrow with a example that clear the cells on the Exceptions sheet instead
of deleting the sheet.

Bed time for me now



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Joe_Hunt via OfficeKB.com" <u45578@uwe wrote in message news:96d174c613b65@uwe...
Looks a lot like what I have. I took some coding from another workbook and
modified it, so maybe your site is where it originated (I think I have a book
at home with an author by your name. Is that you?). After this though the
worksheet is manipulated to gather the information into a coherent form, and
some calculations are done with it. I'd like this process to be kicked off by
changing a percentage in a specified cell (all that begins in the next set of
instructions), and to make that work I need to gather this information
without deleting the sheet, I guess, by having a change event in the coding
of the worksheet. My thought was just to clear the information existing in
the worksheet and then gathering what I needed from the other worksheets. I
was trying not to make my original post too long.

Ron de Bruin wrote:
Is this not working for you then ?
http://www.rondebruin.nl/copy2.htm

Sorry, I'm sometimes not very good at explaining. things. I'd like to copy
the data from cells L11:V93 from every other worksheet in the workbook into

[quoted text clipped - 10 lines]

Application.EnableEvents = True


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

Reply
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
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
copy data in one sheet to multiple sheets in same workbook BrianMultiLanguage Excel Worksheet Functions 4 July 27th 05 07:26 PM


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