LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default How do I make this code shorter? Its Result should be given to var

Sub Try()

Dim x, a, BonRow, BonCol, Bon As Integer

Bon = ActiveCell.Row = 2 And ActiveCell.Row <= 12
BonRow = 12
BonCol = 4

If Bon And (ActiveCell.Column = 2 And ActiveCell.Column <= 4) Then
Cells(2, 4).Select
x = BonRow
Else
If Bon And (ActiveCell.Column = 5 And ActiveCell.Column <= 7) Then
Cells(2, 7).Select
x = BonRow
Else
If Bon And (ActiveCell.Column = 8 And ActiveCell.Column <= 10) Then
Cells(2, 10).Select
x = BonRow
Else
If Bon And (ActiveCell.Column = 11 And ActiveCell.Column <= 13) Then
Cells(2, 13).Select
x = BonRow
Else
If Bon And (ActiveCell.Column = 14 And ActiveCell.Column <= 16) Then
Cells(2, 16).Select
x = BonRow
Else
If Bon And (ActiveCell.Column = 17 And ActiveCell.Column <= 19) Then
Cells(2, 19).Select
x = BonRow
Else
If Bon And (ActiveCell.Column = 20 And ActiveCell.Column <= 22) Then
Cells(2, 22).Select
x = BonRow

End If
End If
End If
End If
End If
End If
End If
End If

Do

ActiveCell.FormulaR1C1 = "=(RC[-2])+(RC[-1])"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=(RC[-2])+(RC[-1])"

Loop Until ActiveCell.Row = x

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
Can I Make This Computation Shorter? Steve[_8_] Excel Discussion (Misc queries) 22 October 28th 07 08:11 PM
Shorter Code Sandy Excel Programming 2 July 7th 07 08:47 PM
How to make a contingent formula shorter... phooey Excel Discussion (Misc queries) 10 January 5th 07 06:04 PM
I wonder if you can make this shorter T Excel Worksheet Functions 0 December 23rd 04 08:47 PM
Shorter code Stu[_13_] Excel Programming 13 September 29th 03 11:27 PM


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

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

About Us

"It's about Microsoft Excel"