VBA - Rewriting a code to avoid pressing "ok" on each loop - extracting data excel files on SharePoint hyperlinks

snowcrash

New Member
Joined
Mar 1, 2018
Messages
10
Hi All,
Every month I have this task of collecting data from about 200 reports, into a main central consolidation file.

The Report is an Excel file stored on SharePoint. All the Data i need is on a hidden tab in one Range.

Process:-
1. I go to the SharePoint site where the files are stored and export the list to excel
2. I then compare the SharePoint list to what is already in my consolidation.
3. With the missing files (new files uploaded to SharePoint since last consolidation) not in my consolidated file i copy a column "C" and place this into a workbook column "C" where i have the following Macro.
4. I press the button and The Macro works and i get my data (Code below)

Issue:
once i activated the macro in i still need to click "OK" each the macro loops and a new file opened.
Is their anyway to re-write the code so i don't have to sit around clicking "OK" and go do something more productive while the code does it work?

/Snowcrash

Code:
     Sub Consolidation()
  
            Dim masterFile As Workbook
            Dim copyWorkbook As Workbook
            Dim lastRow As Long
            Dim rowPosition As Long


            With Application
                .ScreenUpdating = False
                .DisplayAlerts = False
                .AskToUpdateLinks = False
                
            End With


            Set masterFile = ThisWorkbook
            lastRow = Cells(Rows.Count, 3).End(xlUp).Row


            For rowPosition = 4 To lastRow


                Cells(rowPosition, 3).Hyperlinks(1).Follow
                
                Set copyWorkbook = ActiveWorkbook
                With copyWorkbook.Sheets("consolidation")
                    .Visible = True
                    .Range("B4:BCQ44").Copy
                End With


                masterFile.Worksheets(1).Range(Cells(rowPosition, 6).Address).PasteSpecial xlValues
                copyWorkbook.Close SaveChanges:=False


            Next rowPosition


            With Application
                .DisplayAlerts = True
                .ScreenUpdating = True
                .AskToUpdateLinks = True
                
            End With


        End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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