+ Reply to Thread
Results 1 to 5 of 5

Import Sheet1 from file selected via a dialog box

  1. #1
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Import Sheet1 from file selected via a dialog box

    Hi all,

    I've got the following code:

    Please Login or Register  to view this content.
    However, I am getting an "Compile error: Next without For" on the following line:

    Please Login or Register  to view this content.
    But I am confused as I have a For statement, then the Body and the Ending statement?

    Any ideas?

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Import Sheet1 from file selected via a dialog box

    You have a couple of rogue lines in there .. the "With ..." and the "Next tempWorkSheet". Try like this (untested):

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Import Sheet1 from file selected via a dialog box

    Quote Originally Posted by chrisellis250 View Post
    ... But I am confused as I have a For statement, then the Body and the Ending statement? ...
    No, you don't have any "Ending" type statement for "With ... End With" construction:
    Please Login or Register  to view this content.
    and a "For" statement for "For ... Each ... Next" construction:
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re: Import Sheet1 from file selected via a dialog box

    Excellent! Thanks WBD

    Is there a way that I could then name the sheet that I am copying into the workbook as "Schedule" or Schedule1,Schedule2 etc if there already is a sheet called "Schedule" or similar?

  5. #5
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Import Sheet1 from file selected via a dialog box

    Again, untested:

    Please Login or Register  to view this content.
    WBD

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 02-19-2018, 07:46 PM
  2. [SOLVED] A macro which pulls the data from sheet2 to sheet1 basis of scenarios selected in sheet1
    By Manish_Gupta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2015, 01:46 PM
  3. [SOLVED] Macro to import .csv from browse for file location dialog box.
    By gutterball in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2014, 08:30 AM
  4. [SOLVED] import selected lines from a text file
    By harkirat777 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2013, 11:56 AM
  5. [SOLVED] MACRO: Store name of selected file as string w/ import data file dialog box
    By AnnieMcken in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 02:13 PM
  6. Import xml data by letting the user choose from file dialog box
    By victor.enbom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-19-2012, 03:13 AM
  7. Import selected file to specific sheet
    By jnate in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-02-2009, 09:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1