LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default shorten a macro



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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I shorten this any? Gregory Day Excel Worksheet Functions 1 April 10th 08 06:29 PM
shorten connection time <<Macro Tweak needed Dan Excel Programming 0 April 17th 07 07:47 AM
How can i shorten this macro? LMI Excel Programming 3 April 3rd 06 04:13 PM
Shorten a Macro mully Excel Discussion (Misc queries) 7 December 30th 05 05:52 PM
Macro to shorten a list JGB Excel Discussion (Misc queries) 2 August 5th 05 10:31 AM


All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"