Excel not responding when run macro on the shared workbook

vanilz

New Member
Joined
Sep 19, 2019
Messages
9
Need help on below.

Basically, I want to combine all the data from worksheets into one worksheet. And this workbook is shared and will be used by multiple users at the same time and save the files before combine. However, when run the macro, it is not responding.


Code:
Code:
Sub Combine()    Dim J As Integer
    Dim sourceSheet As Worksheet
    
    'Disable Screen Updating - stop screen flickering
    Application.ScreenUpdating = False
    
    'set the Masterlist sheet as active
    Set sourceSheet = ActiveSheet
    
   
    'delete previous rows
    Sheets(1).Activate
    Rows("5:" & Rows.Count).Delete
    
    ' copy headings
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A5")


    ' work through sheets
    For J = 2 To Sheets.Count ' from sheet 2 to last sheet
        Sheets(J).Activate ' make the sheet active
        Range("A2").Select
        Selection.CurrentRegion.Select ' select all cells in this sheets


        ' select all lines except title
        Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select


        ' copy cells selected in the new sheet on last line
        Selection.Copy Destination:=Sheets(1).Range("A9999").End(xlUp)(2)
    Next
       
    Sheets(1).Range("A5").AutoFilter
    Sheets(1).Columns.AutoFit
    
    ' return to Masterlist sheet
    Call sourceSheet.Activate
    
    'Enable Screen Updating and Events
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
It is running on Excel 2010


Need help on below.

Basically, I want to combine all the data from worksheets into one worksheet. And this workbook is shared and will be used by multiple users at the same time and save the files before combine. However, when run the macro, it is not responding.


Code:
Code:
Sub Combine()    Dim J As Integer
    Dim sourceSheet As Worksheet
    
    'Disable Screen Updating - stop screen flickering
    Application.ScreenUpdating = False
    
    'set the Masterlist sheet as active
    Set sourceSheet = ActiveSheet
    
   
    'delete previous rows
    Sheets(1).Activate
    Rows("5:" & Rows.Count).Delete
    
    ' copy headings
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A5")


    ' work through sheets
    For J = 2 To Sheets.Count ' from sheet 2 to last sheet
        Sheets(J).Activate ' make the sheet active
        Range("A2").Select
        Selection.CurrentRegion.Select ' select all cells in this sheets


        ' select all lines except title
        Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select


        ' copy cells selected in the new sheet on last line
        Selection.Copy Destination:=Sheets(1).Range("A9999").End(xlUp)(2)
    Next
       
    Sheets(1).Range("A5").AutoFilter
    Sheets(1).Columns.AutoFit
    
    ' return to Masterlist sheet
    Call sourceSheet.Activate
    
    'Enable Screen Updating and Events
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Please help with the code.. How to make it work to run in Shared workbook.

I added macro to unshared it from the beginning and run the macro and thereafter shared the workbook again.

Tried to add some contents before run the macro but the data is not saved. When the second person who open the workbook, it doesn't show as SHARED and no prompt to open read-only. Also, the data added is not available.

Could you please help with the macro? I have been struggling how to make it work.. at least it can be combine data, on shared workbook and saved multi user changes.

Unshared and shared code:
Code:
If ActiveWorkbook.MultiUserEditing Then
        Application.DisplayAlerts = False
        ActiveWorkbook.ExclusiveAccess
        Application.DisplayAlerts = True
    End If

If Not ActiveWorkbook.MultiUserEditing Then
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs ActiveWorkbook.Name, accessmode:=xlShared
        Application.DisplayAlerts = True
    End If
 
Upvote 0

Forum statistics

Threads
1,223,753
Messages
6,174,307
Members
452,554
Latest member
Louis1225

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