View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default How do I make this code shorter? Its Result should be given to


Actually your code will not run as it does not compile.
It has an extra End If. You must have a very compliant computer. <g
You also did not say what the code is meant to do.
Nevertheless, I decided that it is designed to calculate the square
footage of the apartments you are remodeling. So this is your lucky day...
'--
Sub Try_R1()
Dim x As Long
Dim BonRow As Long
Dim BonCol As Long
Dim Bon As Long
Dim Rw As Long
Dim Cl As Long

Bon = ActiveCell.Row = 2 And ActiveCell.Row <= 12
If Not Bon Then Exit Sub
BonRow = 12
BonCol = 4
x = BonRow
Cl = ActiveCell.Column

Select Case True
Case Cl = 2 And Cl <= 4
Call MoreFormulas(Cells(2, 4), x)
Case Cl = 5 And Cl <= 7
Call MoreFormulas(Cells(2, 7), x)
Case Cl = 8 And Cl <= 10
Call MoreFormulas(Cells(2, 10), x)
Case Cl = 11 And Cl <= 13
Call MoreFormulas(Cells(2, 13), x)
Case Cl = 14 And Cl <= 16
Call MoreFormulas(Cells(2, 16), x)
Case Cl = 17 And Cl <= 19
Call MoreFormulas(Cells(2, 19), x)
Case Cl = 20 And Cl <= 22
Call MoreFormulas(Cells(2, 22), x)
End Select
End Sub
'--
Function MoreFormulas(ByRef rCell As Excel.Range, ByRef xx As Long)
Do
rCell.FormulaR1C1 = "=(RC[-2])+(RC[-1])"
Set rCell = rCell.Offset(1, 0)
Loop Until rCell.Row = xx
End Function
--
Jim Cone
Portland, Oregon USA





"Jay"
wrote in message
No actually this does works, the problem is that as I look at this like its only reiterating, so im figuring a way how to make
this code short and easier to read





"Jim Cone" wrote:
What is the code supposed to do?
Are you a having problem with it? (If so, try removing one "End If")
--
Jim Cone
Portland, Oregon USA




..