Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

How to get MOST RECENT Excel File in Sharepoint using command button VBA?

Below is my code. I just manually edit the time to get the excel on that sharepoint but that file refreshes every 30minutes with new excel. So I want to get the most recent everytime it refreshes without editing the time

Private Sub CommandButton1_Click()
    Dim SharePoint As Workbook
    Dim Desktop As Workbook
  

 Set SharePoint = Workbooks.Open("https://work.sharepoint.com/sites/group/Excel Hourly Wip/Excel Wip as of Jan 27 05_12 PM.xlsm")

 Set Desktop = ThisWorkbook
 
 SharePoint.Sheets("ICM").Range("A2:A20000").Copy
 Desktop.Sheets("ICM").Range("A2:A20000").PasteSpecial
 
    SharePoint.Sheets("ICM").Range("D2:D20000").Copy
 Desktop.Sheets("ICM").Range("B2:B20000").PasteSpecial
    
    SharePoint.Sheets("ICM").Range("G2:G20000").Copy
 Desktop.Sheets("ICM").Range("C2:C20000").PasteSpecial
    
       SharePoint.Sheets("ICM").Range("H2:H20000").Copy
 Desktop.Sheets("ICM").Range("D2:D20000").PasteSpecial
    
           SharePoint.Sheets("ICM").Range("I2:I20000").Copy
 Desktop.Sheets("ICM").Range("E2:E20000").PasteSpecial
 
           SharePoint.Sheets("ICM").Range("W2:W20000").Copy
 Desktop.Sheets("ICM").Range("F2:F20000").PasteSpecial
 
           SharePoint.Sheets("ICM").Range("Z2:Z20000").Copy
 Desktop.Sheets("ICM").Range("G2:G20000").PasteSpecial
 
           SharePoint.Sheets("ICM").Range("AA2:AA20000").Copy
 Desktop.Sheets("ICM").Range("H2:H20000").PasteSpecial
 
           SharePoint.Sheets("ICM").Range("AB2:AB20000").Copy
 Desktop.Sheets("ICM").Range("I2:I20000").PasteSpecial
 
           SharePoint.Sheets("ICM").Range("AE2:AE20000").Copy
 Desktop.Sheets("ICM").Range("J2:J20000").PasteSpecial
 
 
 SharePoint.Close
 
 


End Sub
question from:https://stackoverflow.com/questions/65919591/how-to-get-most-recent-excel-file-in-sharepoint-using-command-button-vba

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...