Collate the data from excel when it is opening

Rajneesh Rawat

New Member
Joined
Mar 31, 2017
Messages
36
Hi Team,

I am stuck in a scenario where Superviosor need to collate the data from all team, twice or thrice in a day.

Below is my code which is working fine if the file is closed and we want to collate the data with all type of excel whether user is working on this file or it is close.

I am getting error "Someone else is working on this file. Please try again later"

Is there any other solution of this issue or can you review the below code and assist me what need to be change.

Code:
aa = 0
For Each fl In fld.Files

Set akb = Workbooks.Open(fl, ReadOnly:=True)

If aa >= 1 Then
    lrw = wkb.Sheets(Format(Date, "DD MMM")).Cells(Rows.Count, 1).End(xlUp).Row + 1
    akb.Sheets(1).Unprotect "NB123"
    akb.Sheets(1).Range("A1").CurrentRegion.Offset(1).Copy wkb.Sheets(Format(Date, "DD MMM")).Range("A" & lrw)
    aa = aa + 1
   akb.Close False
ElseIf aa = 0 Then
    lrw = wkb.Sheets(Format(Date, "DD MMM")).Cells(Rows.Count, 1).End(xlUp).Row
    'akb.Sheets(1).Activate
    akb.Sheets(1).Unprotect "NB123"
    akb.Sheets(1).Range("A1").CurrentRegion.Copy wkb.Sheets(Format(Date, "DD MMM")).Range("A" & lrw)
    aa = aa + 1
  
  akb.Close False

End If
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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