|
-
Jan 22nd, 2010, 06:06 AM
#1
Thread Starter
New Member
Correct myCode please
Please some one correct following code in VBA.
cmb = 6
If Sheet1.ComboBox & cmb.Text = "15 Days" Then sl_by = 2
If Sheet1.ComboBox & cmb.Text = "30 Days" Then sl_by = 1
Thank You
-
Jan 22nd, 2010, 06:09 AM
#2
Re: Correct myCode please
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 22nd, 2010, 07:15 AM
#3
Frenzied Member
Re: Correct myCode please
 Originally Posted by erksarma
Please some one correct following code in VBA.
cmb = 6
If Sheet1.ComboBox & cmb.Text = "15 Days" Then sl_by = 2
If Sheet1.ComboBox & cmb.Text = "30 Days" Then sl_by = 1
Thank You 
if you replace the second line of your code by the value of cmb i.e,6 then it becomes 6.text.......does it have any meaning
-
Jan 22nd, 2010, 07:37 AM
#4
Fanatic Member
Re: Correct myCode please
deleted.. I understand now and can't help.
Last edited by sgrya1; Jan 22nd, 2010 at 07:50 AM.
-
Jan 22nd, 2010, 01:29 PM
#5
Lively Member
Re: Correct myCode please
What problem do you want to solve with this code?
-
Jan 22nd, 2010, 01:44 PM
#6
Fanatic Member
Re: Correct myCode please
I think I understand the problem. There are a number of comboboxes named ComboBox1 to say ComboBox9.
VBA doesn't use control arrays so it's a little difficult without writing
If Sheet1.ComboBox6.Text = "15 Days" Then sl_by = 2
dealing with each ComboBox seperately.
-
Jan 22nd, 2010, 03:33 PM
#7
Re: Correct myCode please
vb Code:
cmb = 6 If Sheet1.olebjects("combobox" & cmb).object.Text = "15 Days" Then sl_by = 2 If Sheet1.olebjects("combobox" & cmb).object.Text = "30 Days" Then sl_by = 1
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 24th, 2010, 02:01 AM
#8
Thread Starter
New Member
Re: Correct myCode please
Thank U one and all especially westconn1.
westconn1 reply helped me Thank You once again. I take u for my guru. I am an ameture. Please help me in the following problem.
with the same project, as it may be clear to you I have placed some more controls in my workbook. They include DatePickers, Lables, Combos and CommondButtons etc., and some User Defined Functions. I am trying to distribute my work to my other offices. Some of the systems are not supporting the DatePickers. Probobly the references of VB controls are not activiated on those machines. I would like to give them a bundle of all such controls and UDFs so that tehy can use my workbook as I do on my machine. Help solicited please.
-
Jan 24th, 2010, 05:24 AM
#9
Re: Correct myCode please
you can export modules with udfs, then import on other machines
a simpler solution, might be to build an excel addin (.xla), which can be distributed to all users
don't know about the datepickers, check for any missing references on machines where they don't work
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|