MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 20th, 2002, 07:15 PM   #1
Von Pookie
MrExcel MVP, Administrator
 
Von Pookie's Avatar
 
Join Date: Feb 2002
Location: The act or process of locating.
Posts: 13,384
Default

Ok. I give. I've gotten so far by myself, and was doing so well without having to ask a question, but nooooo...this had to "stump me", as it were.

On my userform, I will enter a page number in TextBox3, and select a year from ComboBox1.

So if I enter 123 in the textbox (however this can be a 1 to 3 digit number), then choose either ('00) or ('01) from the combobox.

How can I have these both end up in cell C3 as 123 ('00)? I've been messing with it all afternoon, and am severely stuck.

Thanks,

_________________
~*Kristy*~

"Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam."



[ This Message was edited by: Von Pookie on 2002-05-21 12:54 ]
Von Pookie is offline   Reply With Quote
Old May 20th, 2002, 07:26 PM   #2
Jack in the UK
 
Join Date: Feb 2002
Posts: 3,063
Default

Hi Kristy

your need VBA to do this can you post you code so far ill have a play see if i can make something usable


__________________
Free Excel based Web Toolbar available here.

Jack in the UK
J & R Excel Solutions
"making Excel work for you"
Jack in the UK is offline   Reply With Quote
Old May 20th, 2002, 09:05 PM   #3
Von Pookie
MrExcel MVP, Administrator
 
Von Pookie's Avatar
 
Join Date: Feb 2002
Location: The act or process of locating.
Posts: 13,384
Default

I wasn't sure if anyone would need the code or not. Here you go, Jack:



Private Sub UserForm_Click()

TextBox1.SetFocus

End Sub

Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
Call CommandButton1_Click
End If
End Sub
Private Sub ComboBox1_Click()

ComboBox1.RowSource = ("Products!I1:I2")
Application.OnTime Now, "DropDown_ComboBox"


End Sub

Private Sub CommandButton1_Click()

ActiveSheet.Unprotect

Range("$A$3").Select
Selection.EntireRow.Insert

Range("$A$3") = TextBox1.Value
Range("$B$3") = TextBox2.Value
Range("$C$3") = TextBox3.Value
Range("$D$3") = TextBox4.Value


If TextBox3.Value = "" And ComboBox1.Value = "" Then
Range("$C$3").Select
ActiveCell.FormulaR1C1 = "Not Listed"
Range("A3:D3").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If

Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select


ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Dim ctl As Control

For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then ctl.Text = ""
If TypeName(ctl) = "ComboBox" Then ctl.Text = ""
Next ctl

TextBox1.SetFocus

End Sub


Private Sub CommandButton2_Click()

Dim ctl As Control

For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then ctl.Text = ""
If TypeName(ctl) = "ComboBox" Then ctl.Text = ""
Next ctl


UserForm1.Hide
TextBox1.SetFocus

End Sub
Private Sub CommandButton3_Click()

Dim ctl As Control

For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then ctl.Text = ""
If TypeName(ctl) = "ComboBox" Then ctl.Text = ""
Next ctl

TextBox1.SetFocus

End Sub


_________________
~*Kristy*~

"Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam."



[ This Message was edited by: Von Pookie on 2002-05-20 16:05 ]
Von Pookie is offline   Reply With Quote
Old May 20th, 2002, 09:17 PM   #4
NateO
MrExcel MVP
Admin
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,639
Default

Hi Kristy, does changing

Range("$C$3") = TextBox3.Value

to

Range("$C$3") = TextBox3.Value & " " & ComboBox1.Value

Help?
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old May 20th, 2002, 10:57 PM   #5
Von Pookie
MrExcel MVP, Administrator
 
Von Pookie's Avatar
 
Join Date: Feb 2002
Location: The act or process of locating.
Posts: 13,384
Default

Yay! Yes it did! I was closer today than I thought I was

But, now, after I click ok (commandbutton1) and add it to my listing, then I click cancel (commandbutton2) to "hide" the form and now it's telling me: "the macro test2.xls'!DropDown_ComboBox' cannot be found."

Obviously, it didn't do this before. Why would it start this now?

Strange...I just added it to the exact same workbook here at work, and it worked fine. Methinks the laptop may be a bit screwy with VBA (it is running a different version of Excel )

Thanks, Nate

_________________
~*Kristy*~

"Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam."



[ This Message was edited by: Von Pookie on 2002-05-21 06:02 ]
Von Pookie is offline   Reply With Quote
Old May 21st, 2002, 02:14 PM   #6
NateO
MrExcel MVP
Admin
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,639
Default

Hello Kristy,
Quote:
the form and now it's telling me: "the macro test2.xls'!DropDown_ComboBox' cannot be found."
It sounds to me like me.controls is associating itself with another file that is located in your office, but not at home (at work your actually clearing several forms when you click this). Perhaps use:

For Each Ctl In UserForm1.Controls


instead.
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old May 21st, 2002, 02:22 PM   #7
Von Pookie
MrExcel MVP, Administrator
 
Von Pookie's Avatar
 
Join Date: Feb 2002
Location: The act or process of locating.
Posts: 13,384
Default

The most amazing thing just happened. I started getting that message here at work, too, right before I saw this response. What timing

Now it's started to do it after I added a message box to come up if certain textboxes are blank. It was working fine until I got the message box to work like I want it to, of course. What I added before it started is in red. I've changed all of the me.controls to UserForm1.controls, as well. Still doing it.


Private Sub CommandButton1_Click()

If TextBox1.Value = "" And TextBox2.Value = "" Then
MsgBox "Please enter an Item Description and Item Number to continue."
TextBox1.SetFocus

Else


ActiveSheet.Unprotect

Range("$A$3").Select
Selection.EntireRow.Insert

Range("$A$3") = TextBox1.Value
Range("$B$3") = TextBox2.Value
Range("$C$3") = TextBox3.Value & " " & ComboBox1.Value
Range("$D$3") = TextBox4.Value


If TextBox3.Value = "" And ComboBox1.Value = "" Then
Range("$C$3").Select
ActiveCell.FormulaR1C1 = "Not Listed"
Range("A3:D3").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If

Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select


ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Dim ctl As Control

For Each ctl In UserForm1.Controls
If TypeName(ctl) = "TextBox" Then ctl.Text = ""
If TypeName(ctl) = "ComboBox" Then ctl.Text = ""
Next ctl

TextBox1.SetFocus

End If
End Sub



Thanks,

_________________
~*Kristy*~

"Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam."



[ This Message was edited by: Von Pookie on 2002-05-21 09:24 ]
Von Pookie is offline   Reply With Quote
Old May 21st, 2002, 03:38 PM   #8
NateO
MrExcel MVP
Admin
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,639
Default

How are you launching the userform (if by button, try reassigning the button's procedure)?

I can't see anything in your code linking externally.
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old May 21st, 2002, 03:48 PM   #9
NateO
MrExcel MVP
Admin
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,639
Default

Found the issue in your original code posting in the combobox1_click procedure:


Application.OnTime Now, "DropDown_ComboBox"


 

Must be a procedure that's no longer available, you'll want to correct this code, if not necessary, eliminate it.

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-21 10:50 ]
NateO is offline   Reply With Quote
Old May 21st, 2002, 03:49 PM   #10
Von Pookie
MrExcel MVP, Administrator
 
Von Pookie's Avatar
 
Join Date: Feb 2002
Location: The act or process of locating.
Posts: 13,384
Default

You snuck in there on me

I deleted the line, and ended up changing where the source row is, which I changed in the code and in the properties for the combobox.

So, now I have

ComboBox1.RowSource = ("Products!I1:K1")

And nothing is coming up when I click on the drop down arrow in the combobox.

On the bright side, I'm not getting that error anymore


_________________
~*Kristy*~

"Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam."



[ This Message was edited by: Von Pookie on 2002-05-21 11:06 ]
Von Pookie is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 12:39 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes