Hi, I should have written thank you both! regards, seba On 11 sep., 23:04, Seba <sebastjan.hri...@gmail.com> wrote: > Sam, thank you very much for your help and efforts. > > Works like a charm. You just made my monday easier:) > > regards, > seba > > On 11 sep., 22:55, Sam Mathai Chacko <samde...@gmail.com> wrote: > > > > > > > > > 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 <http://twitter.com/exceldailytip> > > > 2. Join our LinkedIN group > > > @http://www.linkedin.com/**groups?gid=1871310<http://www.linkedin.com/groups?gid=1871310> > > > 3. Excel tutorials > > > athttp://www.excel-macros.**blogspot.com<http://www.excel-macros.blogspot.com/> > > > 4. Learn VBA Macros > > > athttp://www.quickvba.blogspot.**com<http://www.quickvba.blogspot.com/> > > > 5. Excel Tips and Tricks > > > athttp://exceldailytip.blogspot.**com<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<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 <http://twitter.com/exceldailytip> > > > 2. Join our LinkedIN group > > > @http://www.linkedin.com/**groups?gid=1871310<http://www.linkedin.com/groups?gid=1871310> > > > 3. Excel tutorials > > > athttp://www.excel-macros.**blogspot.com<http://www.excel-macros.blogspot.com/> > > > 4. Learn VBA Macros > > > athttp://www.quickvba.blogspot.**com<http://www.quickvba.blogspot.com/> > > > 5. Excel Tips and Tricks > > > athttp://exceldailytip.blogspot.**com<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<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