View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Excel code optimization

Why are you re-posting, why not just read replies to the earlier duplicate
question?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"deepika :excel help" wrote in
message ...
How do i optimize the following code wit 31 cases
here i is the row index (dynamic) and in everycase the estimate gets
subtracted by multiples of 8. so for case 31 we need to have 8*31= 248 as
a
subtraction to the estimate. This is quite urgent and i do not know prog
at
all. Kindly help
Select Case (x)

Case 1:
Sheets("FTP").Cells(i, 3) = 8
Sheets("FTP").Cells(i, 4) = estimate - 8
Case 2:
Sheets("FTP").Cells(i, 3) = 8
Sheets("FTP").Cells(i, 4) = 8
Sheets("FTP").Cells(i, 5) = estimate - 16
Case 3:
Sheets("FTP").Cells(i, 3) = 8
Sheets("FTP").Cells(i, 4) = 8
Sheets("FTP").Cells(i, 5) = 8
Sheets("FTP").Cells(i, 6) =estimate - 24

Case 4:
Sheets("FTP").Cells(i, 3) = 8
Sheets("FTP").Cells(i, 4) = 8
Sheets("FTP").Cells(i, 5) = 8
Sheets("FTP").Cells(i, 6) = 8
Sheets("FTP").Cells(i, 7) = estimate - 32
Case 5:
Sheets("FTP").Cells(i, 3) = 8
Sheets("FTP").Cells(i, 4) = 8
Sheets("FTP").Cells(i, 5) = 8
Sheets("FTP").Cells(i, 6) = 8
Sheets("FTP").Cells(i, 7) = 8
Sheets("FTP").Cells(i, 8) = estimate - 40

Case 6:
....
case 31 :
End Select