Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I receive the error code 13 when I close the workbook. here is the code :
Private Sub CLIENT_Change() Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(CLIENT.Value + 2, 1) End Sub This sub's function is to put a text value taked from the CLIENT combobox value and to put it in a specific cell. tx -- Yvester |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Him
CLIENT.Value returns a string, say "Hello" therefore CLIENT.Value + 2 returns 'hello2' If you are looking for the index of the selection within the combo, use: Client.ListIndex + 2 ''' Note ListIndex starts at 0 for the first item If your combo contains numbers (stored as strings) and you meant to use these numbers, you have to convert them from strings to numbers first: Clng(Client.Value) + 2 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: I receive the error code 13 when I close the workbook. here is the code : Private Sub CLIENT_Change() Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(CLIENT.Value + 2, 1) End Sub This sub's function is to put a text value taked from the CLIENT combobox value and to put it in a specific cell. tx -- Yvester |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, maybe I didn't explain correctly my toughts.
the CLIENT.Value + 2 refeer to a specific row, based on the value returned by the CLIENT combobox + a constant (2 in this case). and then, this value (string) is put in a specific cell (5,2 or "B5". Sorry for my poor explications on the first post Yves -- Yvester "sebastienm" wrote: Him CLIENT.Value returns a string, say "Hello" therefore CLIENT.Value + 2 returns 'hello2' If you are looking for the index of the selection within the combo, use: Client.ListIndex + 2 ''' Note ListIndex starts at 0 for the first item If your combo contains numbers (stored as strings) and you meant to use these numbers, you have to convert them from strings to numbers first: Clng(Client.Value) + 2 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: I receive the error code 13 when I close the workbook. here is the code : Private Sub CLIENT_Change() Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(CLIENT.Value + 2, 1) End Sub This sub's function is to put a text value taked from the CLIENT combobox value and to put it in a specific cell. tx -- Yvester |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
the CLIENT.Value + 2 refeer to a specific row
I understand, but it don't think it is what it does. What does the following expression returns (in the _Change sub): debug.print CLIENT.Value + 2 If Client.Value retuns the a 'number' (as a String though: "10" and not 10), try replacing the above expression with Clng(Client.Value) + 2 Still having the issue? -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: Hi, maybe I didn't explain correctly my toughts. the CLIENT.Value + 2 refeer to a specific row, based on the value returned by the CLIENT combobox + a constant (2 in this case). and then, this value (string) is put in a specific cell (5,2 or "B5". Sorry for my poor explications on the first post Yves -- Yvester "sebastienm" wrote: Him CLIENT.Value returns a string, say "Hello" therefore CLIENT.Value + 2 returns 'hello2' If you are looking for the index of the selection within the combo, use: Client.ListIndex + 2 ''' Note ListIndex starts at 0 for the first item If your combo contains numbers (stored as strings) and you meant to use these numbers, you have to convert them from strings to numbers first: Clng(Client.Value) + 2 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: I receive the error code 13 when I close the workbook. here is the code : Private Sub CLIENT_Change() Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(CLIENT.Value + 2, 1) End Sub This sub's function is to put a text value taked from the CLIENT combobox value and to put it in a specific cell. tx -- Yvester |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I try the Cint and it works but now, it's the error 94 who pop up! geezzzz...
-- Yvester "sebastienm" wrote: the CLIENT.Value + 2 refeer to a specific row I understand, but it don't think it is what it does. What does the following expression returns (in the _Change sub): debug.print CLIENT.Value + 2 If Client.Value retuns the a 'number' (as a String though: "10" and not 10), try replacing the above expression with Clng(Client.Value) + 2 Still having the issue? -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: Hi, maybe I didn't explain correctly my toughts. the CLIENT.Value + 2 refeer to a specific row, based on the value returned by the CLIENT combobox + a constant (2 in this case). and then, this value (string) is put in a specific cell (5,2 or "B5". Sorry for my poor explications on the first post Yves -- Yvester "sebastienm" wrote: Him CLIENT.Value returns a string, say "Hello" therefore CLIENT.Value + 2 returns 'hello2' If you are looking for the index of the selection within the combo, use: Client.ListIndex + 2 ''' Note ListIndex starts at 0 for the first item If your combo contains numbers (stored as strings) and you meant to use these numbers, you have to convert them from strings to numbers first: Clng(Client.Value) + 2 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: I receive the error code 13 when I close the workbook. here is the code : Private Sub CLIENT_Change() Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(CLIENT.Value + 2, 1) End Sub This sub's function is to put a text value taked from the CLIENT combobox value and to put it in a specific cell. tx -- Yvester |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
:-)
Not sure what error 94 is but i wouldn't be surprised that there is a Null somewhere that messes up things. You may want to cut your line of code into multiple lines to better grasp what's going on and which expression triggers the error. Private Sub CLIENT_Change() Dim row as Long Dim v as variant row= Clng(CLIENT.Value) + 2 v=Worksheets("Donnees").Cells(rows, 1) Worksheets("Facture").Cells(5, 2).Value = v End Sub Note: an Integer only goes up to 32768 so the expression will fail passed that, therfore Cint will fail the same way. Instead, use CLng (Long). -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: I try the Cint and it works but now, it's the error 94 who pop up! geezzzz... -- Yvester "sebastienm" wrote: the CLIENT.Value + 2 refeer to a specific row I understand, but it don't think it is what it does. What does the following expression returns (in the _Change sub): debug.print CLIENT.Value + 2 If Client.Value retuns the a 'number' (as a String though: "10" and not 10), try replacing the above expression with Clng(Client.Value) + 2 Still having the issue? -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: Hi, maybe I didn't explain correctly my toughts. the CLIENT.Value + 2 refeer to a specific row, based on the value returned by the CLIENT combobox + a constant (2 in this case). and then, this value (string) is put in a specific cell (5,2 or "B5". Sorry for my poor explications on the first post Yves -- Yvester "sebastienm" wrote: Him CLIENT.Value returns a string, say "Hello" therefore CLIENT.Value + 2 returns 'hello2' If you are looking for the index of the selection within the combo, use: Client.ListIndex + 2 ''' Note ListIndex starts at 0 for the first item If your combo contains numbers (stored as strings) and you meant to use these numbers, you have to convert them from strings to numbers first: Clng(Client.Value) + 2 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: I receive the error code 13 when I close the workbook. here is the code : Private Sub CLIENT_Change() Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(CLIENT.Value + 2, 1) End Sub This sub's function is to put a text value taked from the CLIENT combobox value and to put it in a specific cell. tx -- Yvester |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oh yeah! I've got it... with your solution Sébastien. It works with the exit
sub before the wanted action... Private Sub Clients_Change() If Clients.ListIndex < 0 Then Exit Sub Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(Clients.Value + 2, 1) End Sub It prevents the case of Clients.Value = null. Thanks for your time Sébastien and also for you, George. Have a nice Holidays everyone -- Yvester "Yvester" wrote: I try the Cint and it works but now, it's the error 94 who pop up! geezzzz... -- Yvester "sebastienm" wrote: the CLIENT.Value + 2 refeer to a specific row I understand, but it don't think it is what it does. What does the following expression returns (in the _Change sub): debug.print CLIENT.Value + 2 If Client.Value retuns the a 'number' (as a String though: "10" and not 10), try replacing the above expression with Clng(Client.Value) + 2 Still having the issue? -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: Hi, maybe I didn't explain correctly my toughts. the CLIENT.Value + 2 refeer to a specific row, based on the value returned by the CLIENT combobox + a constant (2 in this case). and then, this value (string) is put in a specific cell (5,2 or "B5". Sorry for my poor explications on the first post Yves -- Yvester "sebastienm" wrote: Him CLIENT.Value returns a string, say "Hello" therefore CLIENT.Value + 2 returns 'hello2' If you are looking for the index of the selection within the combo, use: Client.ListIndex + 2 ''' Note ListIndex starts at 0 for the first item If your combo contains numbers (stored as strings) and you meant to use these numbers, you have to convert them from strings to numbers first: Clng(Client.Value) + 2 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Yvester" wrote: I receive the error code 13 when I close the workbook. here is the code : Private Sub CLIENT_Change() Worksheets("Facture").Cells(5, 2).Value = Worksheets("Donnees").Cells(CLIENT.Value + 2, 1) End Sub This sub's function is to put a text value taked from the CLIENT combobox value and to put it in a specific cell. tx -- Yvester |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
OnTime code error "can't execute code in break mode" | Excel Programming | |||
Error in Excel VBA Code (Error 91) | Excel Programming | |||
How can I still go to the error-code after a On Error Goto? | Excel Programming | |||
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) | Excel Programming |