×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

renaming a file based on text in a cell

renaming a file based on text in a cell

renaming a file based on text in a cell

(OP)
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,

RE: renaming a file based on text in a cell

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

RE: renaming a file based on text in a cell

(OP)
Thanks johnwm!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources