View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
AGnes AGnes is offline
external usenet poster
 
Posts: 7
Default Summary sheet in a workbook

Thank you all for your help. I am new to VBA so thanks for excusing me for
not even knowing the basic of it!

"AGnes" wrote:

I have the following macro that helps me copy a range of data (from row 10 to
the last row) from each worksheet in a workbook and paste it onto a new
worksheet called "upload". This macro works when I installed it to a
workbook, but doesn't work when I installed it to personal.xls. I do want to
use this on all incoming workbooks from other department. I'd appreciate if
you can help me modify it. Thanks in advance!

--Agnes

Sub Create_Upload_Sheet()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim shLast As Long
Dim Last As Long

On Error Resume Next
If Len(ThisWorkbook.Worksheets.Item("Upload").Name) = 0 Then
On Error GoTo 0
Application.ScreenUpdating = False
Set DestSh = ThisWorkbook.Worksheets.Add
DestSh.Name = "Upload"
For Each sh In ThisWorkbook.Worksheets
If sh.Name < DestSh.Name Then
Last = LastRow(DestSh)
shLast = LastRow(sh)

sh.Range(sh.Rows(10), sh.Rows(shLast)).Copy
With DestSh.Cells(Last + 1, "A")
.PasteSpecial xlPasteValues, , False, False
.PasteSpecial xlPasteFormats, , False, False
Application.CutCopyMode = False
End With

End If
Next
DestSh.Cells(1).Select
Application.ScreenUpdating = True
Else
MsgBox "The upload sheet already exist"
End If
End Sub