This will doubtless turn out to be a typical Noob question but here goes.
I have some code which will tidy up a user input form based on the number of periods selected in F4 but I also want to place the value in G22 into a specified row (obviously not one of those already cleared by the first Then action) without having to duplicate the If statement as a separate line of code.
I've included the code. Ive included the bit that doesnt work in the first If statement just to give an alternative description of what I am trying to achieve. Hope this makes sense
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("F4").Value = 1 Then Range("Q21:Q40,D21:D39").ClearContents , Range("D19").Value = Range("G22")
If Range("F4").Value = 2 Then Range("Q23:Q40,D23:D39").ClearContents
If Range("F4").Value = 3 Then Range("Q25:Q40,D25:D39").ClearContents
If Range("F4").Value = 4 Then Range("Q27:Q40,D27:D39").ClearContents
If Range("F4").Value = 5 Then Range("Q29:Q40,D29:D39").ClearContents
If Range("F4").Value = 6 Then Range("Q31:Q40,D31:D39").ClearContents
If Range("F4").Value = 7 Then Range("Q33:Q40,D33:D39").ClearContents
If Range("F4").Value = 8 Then Range("Q35:Q40,D35:D39").ClearContents
If Range("F4").Value = 9 Then Range("Q37:Q40,D37:D39").ClearContents
If Range("F4").Value = 10 Then Range("Q39:Q40,D39").ClearContents
End Sub
Thanks
Bookmarks