Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default using a cell value to name a newly created workbook

Hello,

I want to use the value in a specific cell to appear as part of the
name of a newly created workbook, which is created following input into
the original workbook. i.e. the user enters the name of a company and
when the macro is run, the name of the company appears as the filename
of the workbook and the workbook is saved to the users desktop,

how would I go about this?

regards,

Matt

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 694
Default using a cell value to name a newly created workbook

Matt:

Try this one. There are two options depending on if it is a new workbook or
the current one.

Option Explicit

Sub nameworkbookondesktop()

'assume the cell is B1

Dim szFilename As String
Dim szDesktop As String
Dim wb As Workbook
Dim objWSHShell As Object

Set objWSHShell = CreateObject("WScript.Shell")
szDesktop = objWSHShell.SpecialFolders("Desktop") & "\"

szFilename = ActiveSheet.Range("B1")

'if a new workbook
Set wb = Workbooks.Add

'if the current workbook
'Set wb = ActiveWorkbook

' save it
wb.SaveAs szDesktop & szFilename
'if you want to close it afterwards
wb.Close True

--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Guerilla" wrote:

Hello,

I want to use the value in a specific cell to appear as part of the
name of a newly created workbook, which is created following input into
the original workbook. i.e. the user enters the name of a company and
when the macro is run, the name of the company appears as the filename
of the workbook and the workbook is saved to the users desktop,

how would I go about this?

regards,

Matt


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
Cell References [email protected] Excel Discussion (Misc queries) 2 November 15th 06 11:37 PM
Setting a cell reference in one sheet that updates a workbook? Danhalawi Excel Discussion (Misc queries) 1 November 7th 06 04:08 PM
One workbook to another . . . Wayne Knazek Excel Discussion (Misc queries) 2 September 26th 06 08:49 PM
insert date Larry Excel Worksheet Functions 28 July 15th 06 02:41 AM
Help with this conditional IF statement C-Dawg Excel Discussion (Misc queries) 3 May 15th 06 06:01 PM


All times are GMT +1. The time now is 03:54 PM.

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

About Us

"It's about Microsoft Excel"