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: 1
Default There has got to be a better way

There has got to be a better way to do this. But I can not figure it out.
This procedure works but it seems to be very long.

I thought that seting a variable might help but not sure how to do it.


Sub ClearPRLine()
'user selects row
'
'MsgBox ActiveCell.Row

Select Case ActiveCell.Row

Case 10, 11 ' if user selected one of these rows
'Rows 10 and 11 clear the contents of columns C,D F,G I,J L,M O,P
Range("C10:D11").Select: Selection.ClearContents
Range("F10:G11").Select: Selection.ClearContents
Range("I10:J11").Select: Selection.ClearContents
Range("L10:M11").Select: Selection.ClearContents
Range("O10:P11").Select: Selection.ClearContents
'now clear the contents of row 11 columns E, H, K, N, Q
Range("E11").Select: Selection.ClearContents
Range("H11").Select: Selection.ClearContents
Range("K11").Select: Selection.ClearContents
Range("N11").Select: Selection.ClearContents
Range("Q11").Select: Selection.ClearContents
'finally clear the contents of row 13 column M
Range("M13").Select: Selection.ClearContents

Case 15, 16
'Rows 15 and 16 clear the contents of columns C,D F,G I,J L,M O,P
Range("C15:D16").Select: Selection.ClearContents
Range("F15:G16").Select: Selection.ClearContents
Range("I15:J16").Select: Selection.ClearContents
Range("L15:M16").Select: Selection.ClearContents
Range("O15:P16").Select: Selection.ClearContents
'now clear the contents of row 11 columns E, H, K, N, Q
Range("E16").Select: Selection.ClearContents
Range("H16").Select: Selection.ClearContents
Range("K16").Select: Selection.ClearContents
Range("N16").Select: Selection.ClearContents
Range("Q16").Select: Selection.ClearContents
'finally clear the contents of row 13 column M
Range("M18").Select: Selection.ClearContents

Case 20, 21
'same as above but rows 20 and 21
Case 25, 26
'ditto
Case 35, 36
'ditto
Case 40, 41
'ditto
End Select

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



All times are GMT +1. The time now is 05:41 PM.

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"