If I am to assume that D is referring to me, then I made a small typo and I did not see the other answer. If my contributions are to this group unwelcome then I have better things to do. GEEEEEEZ!!!
Sub OpenFile() Workbooks.Open Filename:= _ "C:\Users\user\Desktop\2011_" & InputBox("Vnesi nalog") & ".xlsx" End Sub From: Sam Mathai Chacko Sent: Sunday, September 11, 2011 3:55 PM To: excel-macros@googlegroups.com Subject: Re: $$Excel-Macros$$ Open file using criteria from input box Solution already posted D. Could you confirm this was not visible in the forum? If so, then I'd like the moderators to please check why other members are not able to see solutions or answers that are already posted, and waste their development time. Also D, please test the code before posting. Seba, Sub OpenFile() Dim File As String File = InputBox("Vnesi nalog") If Len(Dir("C:\Users\user\Desktop\2011_" & File & ".xlsx")) <> 0 Then Workbooks.Open Filename:="C:\Users\user\Desktop\2011_" & File & ".xlsx" Else MsgBox "File does not exists!" End If End Sub On Sun, Sep 11, 2011 at 11:51 PM, dguillett1 <dguille...@gmail.com> wrote: try Sub OpenFile() Workbooks.Open Filename:= _ "C:\Users\user\Desktop\2011_" InputBox("Vnesi nalog")&".xlsx" End Sub -----Original Message----- From: Seba Sent: Sunday, September 11, 2011 3:31 PM To: MS EXCEL AND VBA MACROS Subject: $$Excel-Macros$$ Open file using criteria from input box Hi all, I need help tweaking one of my simple macros. I would like to open a file after I enter a value into a input box. I have files stored in a specific folder and each one is named like "year_sequence_number", ie: 2011_001. I need a macro which would open a file based on a value I enter. For example: I enter the value 123 and I get the file 2011_123 opened. First I wrote this using my basic knowledge: ------------------------------------------------------------------------------------------------ Sub OpenFile() Dim File As Integer File = InputBox("Vnesi nalog") If File = 001 Then Workbooks.Open Filename:="C:\Users\user\Desktop\2011_001.xlsx" Else Exit Sub End If End Sub ------------------------------------------------------------------------------------------------ Now is it possible and how to modify this so I wouldn't have to copy and paste this a thousand times:) And if possible, I would only like to enter the last three digits as a value: just 001 and not the full name 2011_001. Thank you and best regards, seba -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -- Sam Mathai Chacko -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel