Results 1 to 6 of 6

Using msofiledialogpicker, for wb name (subscript error)

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-20-2021
    Location
    UK
    MS-Off Ver
    2016
    Posts
    126

    Question Using msofiledialogpicker, for wb name (subscript error)

    Objective: use fFile variable, using FileDialog propert,y to extract column E in sheet 1 to another workbook.

    Sub CopyColumnToWorkbook()
    
    Dim sourceColumn As Range, targetColumn As Range, sFile As String
    
    With Application.FileDialog(msoFileDialogFilePicker)
        .ButtonName = "File path"
        If .Show = -1 Then 'if ok is pressed
            sFile = .SelectedItems(1)
        End If
    End With
    
    Set sourceColumn = Workbooks(sFile).Sheets(1).Range("E3:E10000") 'Debugger points to this line 
    Set targetColumn = Workbooks("Target.xlsm").Worksheets(1).Columns("A")
    
    sourceColumn.Copy Destination:=targetColumn
    
    End Sub
    Note: changed file to workbook, but still failed.
    Attached Files Attached Files
    Last edited by immigrated4urjob; 09-08-2021 at 12:36 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error code "run time error 9: subscript out of range
    By iBennett93 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 06-28-2021, 05:03 AM
  2. [SOLVED] Excel VBA set a filter for a exact filename using MsoFileDialogPicker
    By Keebellah in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-07-2020, 04:10 AM
  3. [SOLVED] Help with error run-time error '9" (subscript out of Range)
    By thong127 in forum Excel General
    Replies: 7
    Last Post: 05-02-2018, 02:17 PM
  4. [SOLVED] Run-time error '9': subscript out of range - error occurs on multiple computers except one
    By BrettE in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2014, 11:19 PM
  5. Defining Array - Runtime error 9, Subscript out of range error
    By MaartenW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2012, 07:32 AM
  6. Subscript out of range error - save copy error
    By bg18461 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2006, 11:53 AM
  7. [SOLVED] Type Mismatch error & subscript out of range error
    By Jeff Wright in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2005, 03: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