View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JDonaghue JDonaghue is offline
external usenet poster
 
Posts: 1
Default Command Button Code Stream lining


Ok, I have this barbaric code for a set of 34 separate command buttons
that I am using to archive a set of data here's the code (for 1 of the
34 they all are the same code):

Private Sub CommandButton1_Click()
blah = 3
Bla = "3"
newrow
Set SourceRange = Sheets("Current Patients").Range(Cells(blah, 1),
Cells(blah, 14))
Set destrange = Sheets("Archive").Range("A3")
SourceRange.Copy destrange
Set fixrow = Sheets("Archive").Rows("3:3")
fixrow.RowHeight = 12.75
Set SourceRange = Sheets("Current Patients").Range(Cells(blah + 1,
1), Cells(34, 14))
Set destrange = Sheets("Current Patients").Range("A" + Bla)
SourceRange.Copy destrange
Cells(blah, 1).Select
End Sub

Sub newrow()

Application.CutCopyMode = False
Sheets("Archive").Rows("3:3").Insert Shift:=xlDown
Sheets("Archive").Cells(3, 15).Value = Now

End Sub

Is there a way where I can just dig up the the name so that I can use
the # in the name e.g. It is # of command button +2 I want to use.
There has to be some easy way to do this without the 34 separate
reiterations of code. Another minor question is if I can some how auto
fit the command button sizes to the size of a cell w/o manually doing
it.

Thank you,
Jeremy Donaghue


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/