Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Number generating an error

I have the code below to rename Worksheet 2. When the value in 4, 6 is a
number, e.g. 5, I get an error. Text works fine. Any suggestions?

Thanks

Private Sub CommandButton1_Click()
Sheets(2).Name = Sheets(1).Cells(4, 6).Value + " Equip Info"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Number generating an error

"+" is the addition operator. When used with two text arguments, it
performs the same function as the concatenation operator (&), but when
one argument is text and one is numeric, it causes a type mismatch error.

Use the concatenation operator instead:

Sheets(2).Name = Sheets(1).Cells(4, 6).Value & " Equip Info"



In article ,
Mr. Matt wrote:

I have the code below to rename Worksheet 2. When the value in 4, 6 is a
number, e.g. 5, I get an error. Text works fine. Any suggestions?

Thanks

Private Sub CommandButton1_Click()
Sheets(2).Name = Sheets(1).Cells(4, 6).Value + " Equip Info"
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Number generating an error

Replace your + with a & sign

"Mr. Matt" wrote:

I have the code below to rename Worksheet 2. When the value in 4, 6 is a
number, e.g. 5, I get an error. Text works fine. Any suggestions?

Thanks

Private Sub CommandButton1_Click()
Sheets(2).Name = Sheets(1).Cells(4, 6).Value + " Equip Info"
End Sub

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
Auto generating number RichN Excel Discussion (Misc queries) 1 May 22nd 07 02:04 AM
how do i set up automatic number generating huwzee Excel Worksheet Functions 5 January 25th 07 03:02 PM
Generating an auto number JohannM Excel Worksheet Functions 1 September 4th 06 06:20 PM
Generating Error for UDF Loomah[_3_] Excel Programming 3 June 23rd 06 08:48 PM
Generating (in a random order)each number once from a given number Neil Goldwasser Excel Worksheet Functions 2 December 2nd 05 11:27 PM


All times are GMT +1. The time now is 08:09 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"