Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:55:39+00:00 2026-06-12T18:55:39+00:00

I need to open all Excel files that are in a folder, and copy

  • 0

I need to open all Excel files that are in a folder, and copy every first, 57th, 72th, 73th and 74th row from each file into the same workbook.

This this is what I have so far:

Dim i As Integer
Dim wbOpen As Workbook
Dim MyPath As String
Dim strFilename As String
MyPath = "C:\foldername" 'the folder
strFilename = Dir(MyPath & "\*.xls") 'all excel files in folder

Do Until strFilename = ""

    'here it gives an error, saying it can't open file,
    ' even though it apparently has found it
    wbOpen = Workbooks.Open(strFilename)

    'copy relevant text
    Workbooks(2).Activate
    Sheets("blad1").Rows(1, 57, 72, 73, 74).Copy
    Workbooks(1).Activate
    'select the first empty row
    irow = ActiveSheet.UsedRange.Rows.Count + 1
    'insert the copied
    irow.Insert Shift:=xlDown
    'close the workbook without saving
    Workbooks(2).Close SaveChanges:=False
    Close

Loop
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:55:40+00:00Added an answer on June 12, 2026 at 6:55 pm

    Try it this way:

    MyPath = "C:\foldername" 'the folder
    strFilename = Dir(MyPath & "\*.xls") 'all excel files in folder
    
    Do Until strFilename = ""
    ...
    strFilename=Dir()
    Loop
    

    Tell me if this works

    EDIT: Fix Sheets("blad1").Rows(1, 57, 72, 73, 74).Copy to
    Sheets("blad1").Rows("1, 57, 72, 73, 74").Copy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 250 Microsoft Excel (.xls) files, all in a folder. I need to
i have a code that works on all files in folder and analyise it
My current scenario is that I have 20 Excel files that need to be
All I need is to get the list of currently open documents in the
I need to generate a report where the user can choose All Issues, Open
I'm looking for a library that will allow me to programatically modify Excel files
I need to fetch a sheet from excel to a datatable. I first tried
I am writing a program that will allow me to open excel spreadsheets and
I have a number of text files that I want to import into excel.
Hey can any one tell me should i need open a port for outgoing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.