+ Reply to Thread
Results 1 to 5 of 5

How to open another excel spreadsheet from within excel without displaying the file

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    3

    How to open another excel spreadsheet from within excel without displaying the file

    Hello!

    I'm a new member of the forum and I'm just learning how to use vba in Excel. However, I've run into a problem. I am using the below vba code to open and read another excel spreadsheet to pull data from that file and insert it into my current workbook. It worked perfectly in Excel 2003.

    However, my customer is using Excel 2010, therefore I had to convert the application. The application works, but it actually displays the file that is being opened for a few seconds and then it disappears. I don't want this data file to display at all. How do I prevent this from happening?

    Any and all help is greatly appreciated!

    This is the code I'm using:

    Sub GetInputData()
    ' Get InputData workbook...
    Dim InputDataBook As Workbook
    Dim filter As String
    Dim caption As String
    Dim InputDataFilename As String
    Dim InputDataWorkbook As Workbook
    Dim targetWorkbook As Workbook

    ' make weak assumption that active workbook is the target
    Set targetWorkbook = Application.ActiveWorkbook

    ' get the InputData workbook
    filter = "Text files (*.xls),*.xls"
    caption = "Please Select input file"
    InputDataFilename = Application.GetOpenFilename(filter, , caption)

    Set InputDataWorkbook = Application.Workbooks.Open(InputDataFilename)

    ' copy data from InputData file to target workbook
    Dim targetSheet As Worksheet
    Set targetSheet = targetWorkbook.Worksheets(1)
    Dim sourceSheet As Worksheet
    Set sourceSheet = customerWorkbook.Worksheets(1)

    targetSheet.Range("h11").Value = sourceSheet.Range("F29").Value + sourceSheet.Range("f30").Value
    targetSheet.Range("h12").Value = sourceSheet.Range("F31").Value + sourceSheet.Range("f32").Value
    targetSheet.Range("h13").Value = sourceSheet.Range("F27").Value + sourceSheet.Range("f28").Value
    targetSheet.Range("h14").Value = sourceSheet.Range("F33").Value + sourceSheet.Range("f34").Value
    .
    .
    .
    .
    etc

    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: How to open another excel spreadsheet from within excel without displaying the file

    you didn't post this in the correct forum you should post it in the VBA forum since you are asking for help with VBA

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: How to open another excel spreadsheet from within excel without displaying the file

    also you need to add code tags, select your code and hit the hashtag icon on the quick reply toolbar
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-01-2013
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to open another excel spreadsheet from within excel without displaying the file

    Oops....I apologize. I thought I had posted this on the VBA forum. However, I did find a solution by looking through some of the existing threads. I just needed to add this line:

    Application.ScreenUpdating = False

  5. #5
    Registered User
    Join Date
    05-01-2013
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to open another excel spreadsheet from within excel without displaying the file

    Scott,

    Okay...and thanks for your reply!! I did get it to work by using 'Application.ScreenUpdating = False' . But, I will also try using the code you supplied. I selected the "Excel Functions and Formulas" by accident, I meant to select the forum for 'VBA and Macros'.

    Charisse

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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