Macro - I want to past filename into cell

  • Thread starter Thread starter a924fan
  • Start date Start date
A

a924fan

MACRO --- I have:
NewFileNumber = Application.GetOpenFilename(FileFilter:="All Files
(*.*),*.*", Title:="Select a HEX file to import")
Open NewFileNumber For Input As #1

If filename is C:/temp.txt, I want to past that to a cell. I can copy
and past the content of variable 'NewFileNumber' if I knew how to copy
the content of 'NewFileNumber' . It is probaably easy to do but I just
don't know how to do it. Research is drawing a blank. TIA.
 
You can just plop that variable's contents directly into a cell:

Dim NewFileNumber as variant
NewFileNumber = Application.GetOpenFilename(FileFilter:="All Files (*.*),*.*", _
Title:="Select a HEX file to import")
if newfilenumber = false then
'user hit cancel
exit sub '???
end if

worksheets("sheet1").range("A1").value = newfilenumber

'rest of your code
Open NewFileNumber For Input As #1
 
Back
Top