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 |
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 |
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 |
All times are GMT +1. The time now is 05:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com