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: 29
Default Need More Elegant Solution - Simple Program

Being a very novice programmer I didn't know how to combine the
functions of all these command buttons (examples of two are below, they
are all identical except for the value they are looking for and the
range they copy to). I have about 55 command buttons which are all
executed by one button, very inefficient. Thanks for help in advance!


Private Sub CommandButton54_Click()
Dim r As Range
Set r = Cells.Find(What:="102", After:=Range("A129"),
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)

If Range("A129") = "" Then
r.Offset(1).Resize(1, 4).Copy Range("B6")
Else
r.Offset(1).Resize(1, 4).Copy Range("A" &
Rows.Count).End(xlUp).Offset(1)
End If
End Sub

Private Sub CommandButton55_Click()
Dim r As Range
Set r = Cells.Find(What:="103", After:=Range("A129"),
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)

If Range("A129") = "" Then
r.Offset(1).Resize(1, 4).Copy Range("B7")
Else
r.Offset(1).Resize(1, 4).Copy Range("A" &
Rows.Count).End(xlUp).Offset(1)
End If
End Sub

 
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
Elegant solution for two comparisons Joe Murphy[_2_] Excel Discussion (Misc queries) 9 January 25th 08 10:42 PM
Is there an elegant solution to this table? [email protected] Excel Discussion (Misc queries) 3 July 9th 06 01:31 PM
Working Hours (formula & graph) - any elegant solution? markx Excel Worksheet Functions 1 March 29th 06 02:02 PM
!!!!!!PLEASE HELP ME!!!!!! I'm sure it's a simple solution... Bonnie Excel Discussion (Misc queries) 5 January 20th 06 09:53 PM
elegant programmed solution to local minima with constraints Bill[_32_] Excel Programming 0 July 28th 05 10:04 PM


All times are GMT +1. The time now is 07:19 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"