Results 1 to 3 of 3

Copy columns from one user selected workbook to another

Threaded View

  1. #1
    Registered User
    Join Date
    04-27-2014
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    12

    Copy columns from one user selected workbook to another

    Hi guys,

    I am using this code to copy columns C,D, and P from a user selected workbook into position C,D,E of workbook "Checklist.xlsx" (the one from were I run the VBA code). I don't have a clue about VBA, just have been gathering info, but the code works pretty fine. The only issue is that it opens twice the workbook "wbExt" hence the system prompts me if i want to reopen the already open workbook (anoying).

    Some questions:

    1) Is there a way to copy the 3 columns at once? something like "Columns("C:D, P").Select".
    2) Is there a way to select the workbook from were to copy the column without needing it to actually open?
    3) is there a way to paste the columns starting from row 3 instead of row 1 (Range("C1").Select)?
    I would really appreciate your help.

    Thank you.
    Regards,

    Sub copyfromothersheet()
    '
    ' copyfromothersheet Macro
    '
    Dim wbExt As Workbook
    '
    NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xlsx),*.xlsx", Title:="Select a file")
    If NewFN = False Then
    ' They pressed Cancel
    MsgBox "Stopping because you did not select a file"
    Exit Sub
    Else
    Workbooks.Open Filename:=NewFN
    End If
    Set wbExt = Workbooks.Open(NewFN)
        wbExt.Activate
        Columns("C:D").Select
        Selection.Copy
        Windows("Checklist.xlsx").Activate
        Range("C1").Select
        ActiveSheet.Paste
        wbExt.Activate
        Columns("P:P").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Checklist.xlsx").Activate
        Columns("E:E").Select
        ActiveSheet.Paste
    End Sub
    Last edited by bellfano; 04-27-2014 at 03:19 AM. Reason: to add code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy worksheets and selected columns into new workbook and name each file uniquely
    By Mad-Dog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2013, 08:00 AM
  2. [SOLVED] Import user selected columns from a text file
    By aarho in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-11-2012, 08:28 PM
  3. How to Copy User defined columns from one workbook to another
    By Mah_OS in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-22-2012, 03:49 PM
  4. macro to copy row selected by user
    By jimb0693 in forum Excel General
    Replies: 8
    Last Post: 04-21-2007, 10:11 PM
  5. Opening a user selected workbook
    By David Hall in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2005, 04:06 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