View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
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