ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   type mismatch error (https://www.excelbanter.com/excel-programming/434860-type-mismatch-error.html)

Valeria

type mismatch error
 
Dear experts,
I am getting a type mismatch error with my sub
Private Sub OK_Btn_Click()
Dim Country_Name As String
Country_Name = Me.ComboBox1.Value
Worksheets("Choix").Cells("c15").value = Country_Name
Unload Me
End Sub

I guess it's because Country_Name is a string, and
Worksheets("Choix").Cells("c15").value is read as integer.
How can I set this up so that it works?

Many thanks in advance for your help,
Kind regards,
--
Valeria

BSc Chem Eng Rick

type mismatch error
 
Hi

Change "Cells" to "Range" and your problem should be solved

If this helps please click "Yes"
<<<<<<<<<<

"Valeria" wrote:

Dear experts,
I am getting a type mismatch error with my sub
Private Sub OK_Btn_Click()
Dim Country_Name As String
Country_Name = Me.ComboBox1.Value
Worksheets("Choix").Cells("c15").value = Country_Name
Unload Me
End Sub

I guess it's because Country_Name is a string, and
Worksheets("Choix").Cells("c15").value is read as integer.
How can I set this up so that it works?

Many thanks in advance for your help,
Kind regards,
--
Valeria


Valeria

type mismatch error
 
it works beautifully, many thanks!
--
Valeria


"BSc Chem Eng Rick" wrote:

Hi

Change "Cells" to "Range" and your problem should be solved

If this helps please click "Yes"
<<<<<<<<<<

"Valeria" wrote:

Dear experts,
I am getting a type mismatch error with my sub
Private Sub OK_Btn_Click()
Dim Country_Name As String
Country_Name = Me.ComboBox1.Value
Worksheets("Choix").Cells("c15").value = Country_Name
Unload Me
End Sub

I guess it's because Country_Name is a string, and
Worksheets("Choix").Cells("c15").value is read as integer.
How can I set this up so that it works?

Many thanks in advance for your help,
Kind regards,
--
Valeria


Mike H

type mismatch error
 
Hi,

Change this

Worksheets("Choix").Cells("c15").value = Country_Name

to this
Worksheets("Choix").Range("c15").value = Country_Name
or this
Worksheets("Choix").Cells(14, 3).Value = Country_Name

Mike


Mike

"Valeria" wrote:

Dear experts,
I am getting a type mismatch error with my sub
Private Sub OK_Btn_Click()
Dim Country_Name As String
Country_Name = Me.ComboBox1.Value
Worksheets("Choix").Cells("c15").value = Country_Name
Unload Me
End Sub

I guess it's because Country_Name is a string, and
Worksheets("Choix").Cells("c15").value is read as integer.
How can I set this up so that it works?

Many thanks in advance for your help,
Kind regards,
--
Valeria



All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com