Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi! Anyone who can help me to shorten two macros. both is in the same Userform. Userform has: one combobox two textbox comandbutton The first code is a combobox that has rowsource A4:46, that is the count number for the items in the sheet. and it's a textbox that show the serialnumber to the item in that column B4:B46. The second macro is bound to a button on the userform, and change the serialnumber to the item that is choosed in textbox1, with what is written in textbox2. Here is the first 3 off 46 as u can see, its going to be a large code 'This macro show the old serialnumber in an textbox, just to verify 'that the user choose the right item Private Sub ComboBox1_Change() 'shows the row number to the serialnumber If ComboBox1.Value = 1 Then 'shows the serialnumber TextBox1.Text = Range("B4") Else If ComboBox1.Value = 2 Then TextBox1.Text = Range("B5") Else If ComboBox1.Value = 3 Then TextBox1.Text = Range("B6") Else End If End If End If End Sub Private Sub CommandButton1_Click() ActiveSheet.Unprotect Password:="driller" Application.ScreenUpdating = False 'shows the row number to the serialnumber If ComboBox1.Value = 1 Then TextBox2.SelStart = 0 TextBox2.SelLength = TextBox2.TextLength TextBox2.Copy ActiveSheet.Paste Destination:=Worksheets("5 7.8hwdp").Range("B4") TextBox2.Text = "" Else If ComboBox1.Value = 2 Then TextBox2.SelStart = 0 TextBox2.SelLength = TextBox2.TextLength TextBox2.Copy ActiveSheet.Paste Destination:=Worksheets("5 7.8hwdp").Range("B5") TextBox2.Text = "" Else If ComboBox1.Value = 3 Then TextBox2.SelStart = 0 TextBox2.SelLength = TextBox2.TextLength TextBox2.Copy ActiveSheet.Paste Destination:=Worksheets("5 7.8hwdp").Range("B6") TextBox2.Text = "" Else End If End If End If ActiveSheet.Protect Password:="driller", DrawingObjects:=True, Contents:=True, Scenarios:=True Unload ShngSrlNbrUsrFrm End Sub gratful for all help Aksel *** Sent via Developersdex http://www.developersdex.com *** |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can I shorten this any? | Excel Worksheet Functions | |||
shorten connection time <<Macro Tweak needed | Excel Programming | |||
How can i shorten this macro? | Excel Programming | |||
Shorten a Macro | Excel Discussion (Misc queries) | |||
Macro to shorten a list | Excel Discussion (Misc queries) |