Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

renaming a file based on text in a cell 1

Status
Not open for further replies.

Senselessticker

Electrical
May 28, 2004
395
Hey folks,

I'm trying to rename a file to whatever text is in a particular cell.

I can't seem to find a way to accomplish this. Seems simple I suppose. Can anyone point me in the right direction?

I have no problem using Name OldName As NewName, but how do I define NewName as whatever text is in a particular cell?

I'm new to VBA so please bear with me. I'm sure this shouldn't be difficult.

Thanks,
 
Replies continue below

Recommended for you

You can get the text from a cell using the Value Property of the Range object for that cell
Code:
Private Sub CommandButton1_Click()
myfilename = Range("A37").Value
myfilename = "c:\" & myfilename & ".txt"
Name "c:\test.txt" As myfilename
End Sub


Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting
Steam Engine enthusiasts
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor