Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using a value from an Input box?


Hi I am trying to get excel to ask for a file name,eg C23456.1,using an
input box and then taking that answer and putting it into my code. So
far I have....

ans = InputBox("What is the bank file reference")

ChDir "L:\Accounts\Bank downloads\Todays Download"
Workbooks.OpenText Filename:= _
"L:\Accounts\Bank Downloads\Todays Download\ THE ANSWER
HERE!."

Can someone please help

James


--
James_Newton
------------------------------------------------------------------------
James_Newton's Profile: http://www.excelforum.com/member.php...o&userid=18327
View this thread: http://www.excelforum.com/showthread...hreadid=473687

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Using a value from an Input box?

Hello James,

You can concatenate (join) strings together using an ampersand (&) so
sFullPath below is made up of a) the path, b) the filename and c) the file
extension.

Dim sAns As String
Dim sFullPath As String

sAns = InputBox("What is the bank file reference")
sFullPath = "L:\Accounts\Bank Downloads\Todays Download\ " & sAns & ".xls"

Just an observation, but this method relies on the user typing exactly the
right file name and is therefore liable to errors. Have you considered
letting the user select a file themselves? Search help for "FileDialog
Property" which contains an example.

Hope this helps.

Best regards

John


"James_Newton"
wrote in message
news:James_Newton.1wh0ue_1128585917.3486@excelforu m-nospam.com...

Hi I am trying to get excel to ask for a file name,eg C23456.1,using an
input box and then taking that answer and putting it into my code. So
far I have....

ans = InputBox("What is the bank file reference")

ChDir "L:\Accounts\Bank downloads\Todays Download"
Workbooks.OpenText Filename:= _
"L:\Accounts\Bank Downloads\Todays Download\ THE ANSWER
HERE!."

Can someone please help

James


--
James_Newton
------------------------------------------------------------------------
James_Newton's Profile:
http://www.excelforum.com/member.php...o&userid=18327
View this thread: http://www.excelforum.com/showthread...hreadid=473687



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Using a value from an Input box?

Of course I've just realised you could be asking for a Save file as.........
in which this would obviously work! You could still use the same FileDialod
object with a msoFileDialogSaveAs dialog type.

Best regards

John

"John" wrote in message
...
Hello James,

You can concatenate (join) strings together using an ampersand (&) so
sFullPath below is made up of a) the path, b) the filename and c) the file
extension.

Dim sAns As String
Dim sFullPath As String

sAns = InputBox("What is the bank file reference")
sFullPath = "L:\Accounts\Bank Downloads\Todays Download\ " & sAns & ".xls"

Just an observation, but this method relies on the user typing exactly the
right file name and is therefore liable to errors. Have you considered
letting the user select a file themselves? Search help for "FileDialog
Property" which contains an example.

Hope this helps.

Best regards

John


"James_Newton"
wrote in message
news:James_Newton.1wh0ue_1128585917.3486@excelforu m-nospam.com...

Hi I am trying to get excel to ask for a file name,eg C23456.1,using an
input box and then taking that answer and putting it into my code. So
far I have....

ans = InputBox("What is the bank file reference")

ChDir "L:\Accounts\Bank downloads\Todays Download"
Workbooks.OpenText Filename:= _
"L:\Accounts\Bank Downloads\Todays Download\ THE ANSWER
HERE!."

Can someone please help

James


--
James_Newton
------------------------------------------------------------------------
James_Newton's Profile:
http://www.excelforum.com/member.php...o&userid=18327
View this thread:
http://www.excelforum.com/showthread...hreadid=473687





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to input pictures automatically based on cell input? bsharp Excel Worksheet Functions 9 May 30th 09 07:16 AM
input in number form is being multiplied by 1000 when i input. jweinograd Excel Discussion (Misc queries) 4 April 16th 07 11:18 PM
Have user input converted to uppercase in same cell as input? Shannonn New Users to Excel 1 June 20th 06 03:19 AM
=SUMIF(Input!H2:H718,AZ19,Input!E2:E685)AND(IF ALex Excel Worksheet Functions 2 March 14th 05 09:19 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"