Text from a cell to a macro

Keith.Jackson

Board Regular
Joined
Mar 31, 2005
Messages
115
How can I pull text from a cell in a worksheet and use that text to name a file in a sub routine? For example , the name Bill Smith is in a cell in a worksheet but sometimes that cell is another name. I want to set up a macro to e mail a file to someone with the name in that cell as the file being e mailed.

Thanks
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
You will have some syntax that says "Sendto" or similar, like this:

.sendto "Bill Smith"

replace "Bill Smith" with [a1].text, where [a1] contains the name

eg

.sendto [a1].text
 

Keith.Jackson

Board Regular
Joined
Mar 31, 2005
Messages
115
How can I rename a file created in a macro based on a name in text in a cell on a worksheet?
 

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
Record a macro to "save as" a name:

The look at the macro and replace the name in quotes with:
sheets("Sheet1").range("a1").text
Leave the ".xls" in brackets and use ampersands

You'll end up with seomething like this:

ActiveWorkbook.SaveAs "c:\" & .sheets("Sheet1").range("a1").text & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False

Hope that helps
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,037
Messages
5,856,960
Members
431,841
Latest member
jaybeem

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top