• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

open workbook with specific worksheet

HKB

New Member
Hi,
I have vb code as under

Code:
Sub Macro2()

'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+h
'
    Dim vFile As Variant

    'Showing Text Open Dialog Form
    vFile = Application.GetOpenFilename("Excel Files (*.xlsx)," & _
    "*.xl*", 1, "Select Excel File", "Open", False)

    'If Cancel then exit
    If TypeName(vFile) = "Boolean" Then
        Exit Sub
    End If

    'Open selected file
    Workbooks.Open vFile
    
End Sub
I want to add code that Selected workbook open always with Sheet1 (Sheet1 is a sheet code not Sheet Name) cell "A3"
 
Not sure what you mean, maybe this?
Sheet(1) is the first sheet in the vFile workbook.
Code:
Sub belle()
  Dim vFile As Variant
  vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
    "*.xl*", 1, "Select Excel File", "Open", False)
  If TypeName(vFile) = "Boolean" Then
        Exit Sub
    End If
  Workbooks.Open vFile
    Sheets(1).Activate
End Sub
 
  • Like
Reactions: HKB
Not sure what you mean, maybe this?
Sheet(1) is the first sheet in the vFile workbook.
Code:
Sub belle()
  Dim vFile As Variant
  vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
    "*.xl*", 1, "Select Excel File", "Open", False)
  If TypeName(vFile) = "Boolean" Then
        Exit Sub
    End If
  Workbooks.Open vFile
    Sheets(1).Activate
End Sub
Thanks Belleke...It's work fine...
 
Back
Top