+ Reply to Thread
Results 1 to 5 of 5

Copying Data from Workbook

Hybrid View

ScantilyClared Copying Data from Workbook 08-25-2017, 10:06 AM
Stormin\' Re: Copying Data from Workbook 08-25-2017, 10:19 AM
ScantilyClared Re: Copying Data from Workbook 08-25-2017, 10:25 AM
Stormin\' Re: Copying Data from Workbook 08-29-2017, 06:41 AM
dominicb Re: Copying Data from Workbook 08-25-2017, 10:25 AM
  1. #1
    Registered User
    Join Date
    08-25-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    2

    Question Copying Data from Workbook

    I'm a VBA noob who's hopefully creating a workbook where the user chooses a file and sheet within this file and the main workbook copies data from this sheet from specific (known) cell ranges and worksheet into a sheet in the main workbook (in specific sheet and cell range).


    The file is selected via a file explorer which opens on double clicking the appropriate cell in the main workbook. This returns the full file path as a string in this cell (e.g.
    C:\ExcelTools\Workbook1.xls). I have set up a function to just get the file name (e.g. Workbook1.xls)

    Currently the sheet has to be typed in manually (if anyone has any ideas how to extract sheet names from a file path then I would be grateful!)


    I've been trying (and failing) to find a way to open the selected file, select a range of cells (e.g. A1:R190) from the user-specified sheet name and copy and paste them (or =Range("").Value them) into a range of cells (e.g. B2:S191) another named sheet of the main file.

    I think I'm having an issue with getting the VBA to recognise the selected file and sheet name as they are as strings in cells. Their values may change as the user selects different files so I can't just put one specific file path into the module.

    Any ideas? let me know if anything doesnt make sense!

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    371

    Re: Copying Data from Workbook

    Can you show us your code?
    Design everything to be as simple as possible, but no simpler.

  3. #3
    Registered User
    Join Date
    08-25-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    2

    Re: Copying Data from Workbook

    In terms of copying and pasting i have no code yet

    For the rest of it I essentially have 2 cells with strings containing a file path and a sheet name that the user will change

  4. #4
    Valued Forum Contributor
    Join Date
    03-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    371

    Re: Copying Data from Workbook

    Quote Originally Posted by ScantilyClared View Post
    ...i have no code yet
    yet
    Quote Originally Posted by ScantilyClared View Post
    I've been trying (and failing) to find a way...
    Show us your attempts and we can help guide you to a solution

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Copying Data from Workbook

    Good afternoon ScantilyClared

    ...and welcome to the forum!!

    First things first. It sounds as though you need to tidy up your file open routine before you start identifying cells to copy. VBA provides a built in way of opening files using the standard Excel dialog box - capture the file using this and you don't need to worry about copying the filename into cells and splitting up the file name from the rest of the path and all that kind of thing.

    The link below contains a file which demonstrates the command (GetOpenFilename) and also shows how to extract the sheet names from a closed file. Sort this bit out first, then come back with your questions about copying ranges.
    http://www.appspro.com/Downloads/GetSheetNames.zip

    HTH

    DominicB

+ 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: 10
    Last Post: 05-13-2016, 08:31 AM
  2. Replies: 1
    Last Post: 05-13-2016, 05:01 AM
  3. copying data from a recently opened workbook to the workbook where the form is present
    By Sivaramakrishnan31 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 12:03 PM
  4. [SOLVED] Copying data from a closed workbook into an open workbook ignoring excel filter?
    By reach78 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-17-2013, 12:31 AM
  5. Filtering in another workbook, copying filtered data and pasting in source workbook
    By saadtariq in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2012, 12:55 PM
  6. [SOLVED] Copying data from external workbook into current workbook based on cell value
    By Brontosaurus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-07-2012, 11:17 AM
  7. Replies: 1
    Last Post: 04-01-2006, 03:50 PM

Tags for this Thread

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