Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Help with text function

I am trying to copy a sheet to a different workbook and then rename the
sheet by adding a date from cell B3. I have seen the text() function below
used to get the date from a cell and convert it to text. When I try what is
shown below I get variable not defined. Only part of the macro is shown.
Cell B3 is formatted as Date. What am I doing wrong?



Sheets("SET UP").Select
Sheets("SET UP").Copy Befo=Workbooks("Archives.xls").Sheets(1)
Sheets("SET UP").Select
Sheets("SET UP").Name = "SET UP " & Text(B3, "dd - mm - yyyy")

Thanks,

Albert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with text function

B3 is not a cell reference (to VBA), so it thinks it is probably a variable
name. Since you are using Option Explicit, VB is warning that you are using
a variable named B3 but haven't declared it. What you want to use is
Range("B3").Value, but Text is not a VB function, so another error will be
generated after you do that. The VBA function you want is Format (same
arguments at you are attempting to use in Text).

Rick


"Albert Browne" wrote in message
...
I am trying to copy a sheet to a different workbook and then rename the
sheet by adding a date from cell B3. I have seen the text() function below
used to get the date from a cell and convert it to text. When I try what
is shown below I get variable not defined. Only part of the macro is
shown. Cell B3 is formatted as Date. What am I doing wrong?



Sheets("SET UP").Select
Sheets("SET UP").Copy Befo=Workbooks("Archives.xls").Sheets(1)
Sheets("SET UP").Select
Sheets("SET UP").Name = "SET UP " & Text(B3, "dd - mm - yyyy")

Thanks,

Albert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Help with text function

Hi ALbert

Try
Sheets("SET UP").Name = "SET UP " & Range("B3".Text)
or
Sheets("SET UP").Name = "SET UP " & Format$(Range("B3").Value, "dd - mm -
yyyy")

HTH. Best wishes Harald

"Albert Browne" wrote in message
...
I am trying to copy a sheet to a different workbook and then rename the
sheet by adding a date from cell B3. I have seen the text() function below
used to get the date from a cell and convert it to text. When I try what
is shown below I get variable not defined. Only part of the macro is
shown. Cell B3 is formatted as Date. What am I doing wrong?



Sheets("SET UP").Select
Sheets("SET UP").Copy Befo=Workbooks("Archives.xls").Sheets(1)
Sheets("SET UP").Select
Sheets("SET UP").Name = "SET UP " & Text(B3, "dd - mm - yyyy")

Thanks,

Albert


  #4   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default Help with text function

Albert

You need to change Text (which you have seen as a funtion) to Format,
which you will see works in VBA code.
Also, you need to elaborate on B3 in your code.

The following works for me:

Sub test2()
Sheets("SET UP").Select
Sheets("SET UP").Copy Befo=Workbooks("Book3").Sheets(1)
Sheets("SET UP").Select
Sheets("SET UP").Name = "SET UP" & Format(Range("B3"), "dd - mm -
yyyy")
End Sub

Good luck.

Ken
Norfolk, Va

On Jun 12, 2:55*pm, "Albert Browne"
wrote:
*I am trying to copy a sheet to a different workbook and then rename the
sheet by adding a date from cell B3. I have seen the text() function below
used to get the date from a cell and convert it to text. When I try what is
shown below I get variable not defined. Only part of the macro is shown.
Cell B3 is formatted as Date. What am I doing wrong?

*Sheets("SET UP").Select
*Sheets("SET UP").Copy Befo=Workbooks("Archives.xls").Sheets(1)
*Sheets("SET UP").Select
*Sheets("SET UP").Name = "SET UP " & Text(B3, "dd - mm - yyyy")

Thanks,

Albert


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Help with text function

Maybe:

Sheets("SET UP").Name = "SET UP " &
WorksheetFunction.Text(Range("B3").Value, "dd - mm - yyyy")

HTH,
Paul

--

"Albert Browne" wrote in message
...
I am trying to copy a sheet to a different workbook and then rename the
sheet by adding a date from cell B3. I have seen the text() function below
used to get the date from a cell and convert it to text. When I try what
is shown below I get variable not defined. Only part of the macro is
shown. Cell B3 is formatted as Date. What am I doing wrong?



Sheets("SET UP").Select
Sheets("SET UP").Copy Befo=Workbooks("Archives.xls").Sheets(1)
Sheets("SET UP").Select
Sheets("SET UP").Name = "SET UP " & Text(B3, "dd - mm - yyyy")

Thanks,

Albert



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
using a conditional suffix in text function format syntax=text(value,format_text) Brotherharry Excel Worksheet Functions 1 January 13th 09 03:03 PM
Can Text Function change output text color? epiekarc Excel Discussion (Misc queries) 1 December 31st 08 02:58 AM
Advanced text function (combining text) Johan[_2_] Excel Worksheet Functions 2 March 27th 08 10:05 PM
Using Concatenate function to generate text in Text Box Mary S. Charts and Charting in Excel 1 December 14th 05 08:55 PM
Macro or Function to make text size to suite text Length? lbbss Excel Discussion (Misc queries) 4 December 14th 04 07:53 PM


All times are GMT +1. The time now is 02:08 AM.

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"