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: 160
Default Worksheet Code Expansion

Excel 2000, Sub located in the worksheet code area (not in
the workbook module).

I need to expand the existing code to cover the same
inputs and make the same calculations in two more sections
of the worksheet. As can be seen, only the row numbers
are changing. There ought to be a clean way to do this in
one sub - although I suppose I could repeat the existing
code two more times. But that would be rather messy.

In way of discussion, this code is located in
the "Customer" worksheet code object (clicking on
the "Customer" worksheet tab, view code). Once perfected,
I plan to use the exact same code in three additional
worksheets: "Financial", "Learning and Growth",
and "Internal Business Process." After the code is
perfected, should it be located in each worksheet code
object, or in the workbook code object? Looking for the
cleanest way to do this because this workbook is going to
be converted to a web document in the near future (by
others). Need some advice on this. Thanks.


EXISTING CODE PARAMETERS:
Rows: 19 through 30
P10, V10, U19:U30 (input); X19:X30 (code solutions)
P11, V11, AD19:AD30 (input); AG19:AG30 (code solutions)
P12, V12, AM19:AM30 (input); AP19:AP30 (code solutions)
P13, V13, AV19:AV30 (input); AY19:AY30 (code solutions)

EXPANSION ONE PARAMETERS:
Rows: 51 through 62
P42, V42, U51:U62 (input); X19:X30 (code solutions)
P43, V43, AD51:AD62 (input); AG51:AG62 (code solutions)
P44, V44, AM51:AM62 (input); AP51:AP62 (code solutions)
P45, V45, AV51:AV62 (input); AY51:AY62 (code solutions)

EXPANSION TWO PARAMETERS:
Rows: 83 through 94
P74, V74, U83:U94 (input); X83:X94 (code solutions)
P75, V75, AD83:AD94 (input); AG83:AG94 (code solutions)
P76, V76, AM83:AM94 (input); AP83:AP94 (code solutions)
P77, V77, AV83:AV94 (input); AY83:AY94 (code solutions)


EXISTING CODE:
Dim row As Long
row = Target.row
'Test for entries in row 19 thru 30, the month
If row = 19 And row <= 30 Then
'Test for Target column
Select Case Target.Column
Case 21: 'For entries in column 21, "U"
Cells(row, "X").Value = _
((Target.Value - Range("V10").Value) / _
(Range("P10").Value - Range("V10").Value))
Case 30: 'For entries in column 30, "AD"
Cells(row, "AG").Value = _
((Target.Value - Range("V11").Value) / _
(Range("P11").Value - Range("V11").Value))
Case 39: 'For entries in column 39, "AM"
Cells(row, "AP").Value = _
((Target.Value - Range("V12").Value) / _
(Range("P12").Value - Range("V12").Value))
Case 48: 'For entries in column "AV"
Cells(row, "AY").Value = _
((Target.Value - Range("V13").Value) / _
(Range("P13").Value - Range("V13").Value))
End Select
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
Formula expansion Connie Martin Excel Worksheet Functions 8 November 14th 08 10:04 PM
Formula Expansion Appache Excel Discussion (Misc queries) 3 March 11th 08 08:14 AM
List auto-expansion with protected worksheet GH Excel Discussion (Misc queries) 0 June 26th 07 10:07 PM
Row Expansion Susan Excel Worksheet Functions 11 February 28th 06 07:15 PM
Group Contraction/Expansion in Protected Worksheet rj Excel Worksheet Functions 0 August 19th 05 08:26 PM


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