Merging Sheet data without a Macro

jrfarmer2010

New Member
Joined
Jan 18, 2018
Messages
8
Hello all,

I was tasked with creating a summary page for a workbook with about 25 sheets. I accomplished this used VBA, only to find out that the file is stored and accessed on a SharePoint site which doesn't support Macro use. Is there any other way to combine data from multiple sheets in an automated-type process?

Thanks in advance for any ideas!
Jessica
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
In case it's helpful, here is the code that I'm now trying to replace.

Code:
Sub RunAllMacros()
Dim Sourcesheet As Worksheet
Set Sourcesheet = ThisWorkbook.Worksheets("Client Summary")
ClearContents
addHeaders
CopyDataWithoutHeaders
Call Sourcesheet.Activate
End Sub
Function LastRow(sh As Worksheet)
    On Error Resume Next
    LastRow = sh.Cells.Find(What:="*", _
                            After:=sh.Range("A1"), _
                            Lookat:=xlPart, _
                            LookIn:=xlFormulas, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious, _
                            MatchCase:=False).Row
    On Error GoTo 0
End Function
Function LastCol(sh As Worksheet)
    On Error Resume Next
    LastCol = sh.Cells.Find(What:="*", _
                            After:=sh.Range("A1"), _
                            Lookat:=xlPart, _
                            LookIn:=xlFormulas, _
                            SearchOrder:=xlByColumns, _
                            SearchDirection:=xlPrevious, _
                            MatchCase:=False).Column
    On Error GoTo 0
End Function
Sub ClearContents()
 Application.Calculation = xlManual
 Application.ScreenUpdating = False
  Sheets("MergeSheet").Cells.ClearContents
 Application.ScreenUpdating = True
End Sub
Sub addHeaders()
Dim ws As Worksheet
Dim headers() As Variant
'Define worksheet and desired headers
Set ws = ThisWorkbook.Sheets("MergeSheet")
headers() = Array("Staff Name", "Client", "ER", "Hours", "Comments", "Other")
'Insert headers
With ws
For i = LBound(headers()) To UBound(headers())
    .Cells(1, 1 + i).Value = headers(i)
    Next i
    .Rows(1).Font.Bold = True
    .Rows(1).Borders(xlEdgeBottom).LineStyle = xlContinuous
        
End With

End Sub
Sub CopyDataWithoutHeaders()
    Dim sh As Worksheet
    Dim DestSh As Worksheet
    Dim Last As Long
    Dim LastDest As Long
    Dim shLast As Long
    Dim CopyRng As Range
    Dim StartRow As Long
        
     
    'set references up front
    Set DestSh = ThisWorkbook.Worksheets("MergeSheet")
    
       
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
   
    ' Fill in the start row.
    StartRow = 5
    ' Loop through all worksheets and copy the data to the
    ' summary worksheet.
    For Each sh In ActiveWorkbook.Worksheets
        If sh.Name <> DestSh.Name Then
        If sh.Name <> "Staff Summary" Then
        If sh.Name <> "Client Summary" Then
        If sh.Name <> "Helpers" Then
            ' Find the last row with data on the summary
            ' and source worksheets.
            Last = LastRow(DestSh)
            shLast = LastRow(sh)
            ' If source worksheet is not empty and if the last
            ' row >= StartRow, copy the range.
            If shLast > 0 And shLast >= StartRow Then
                'Set the range that you want to copy
                Set CopyRng = sh.Range(sh.Rows(StartRow), sh.Rows(shLast))
               ' Test to see whether there are enough rows in the summary
               ' worksheet to copy all the data.
                If Last + CopyRng.Rows.Count > DestSh.Rows.Count Then
                   MsgBox "There are not enough rows in the " & _
                   "summary worksheet to place the data."
                   GoTo ExitTheSub
                End If
                ' This statement copies values and formats.
                CopyRng.Copy
                With DestSh.Cells(Last + 1, "A")
                    .PasteSpecial xlPasteValues
                    .PasteSpecial xlPasteFormats
                    Application.CutCopyMode = False
                End With
                
                ' Optional: This statement will copy the sheet
            ' name in the A column.
            DestSh.Cells(Last + 1, "A").Resize(CopyRng.Rows.Count).Value = sh.Name
            End If
        End If
        End If
        End If
        End If
    Next
   
  
ExitTheSub:
    Application.Goto DestSh.Cells(1)
    ' AutoFit the column width in the summary sheet.
    DestSh.Columns.AutoFit
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
           
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,827
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top