I have a table with drop down boxes/lists and formulas in certain columns which I'd like to copy down when a new row is added to the table. For whatever reason, Excel will not copy down these formulas and lists on a consistent basis. As a result, I've turned to VBA to help address this issue. I'm using the following code, which is modified from code provided to me for another worksheet by jaslake:
Public Flag As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)
If Flag = True Then Exit Sub
Dim LR As Long
Dim Cell As Range
LR = Range("A" & Rows.Count).End(xlUp).Row
' If Not Intersect(Target, Columns("A:A")) Is Nothing Then
If Target.Address = "$A$" & LR Then
If Target.Value = "" Then
ActiveSheet.Unprotect
Flag = True
With Sheets("Client Demos").ListObjects("Table3")
.Resize Range("$A$2:$W$" & LR - 1)
End With
Flag = False
ActiveSheet.Protect contents:=True, userinterfaceonly:=True
Else
ActiveSheet.Unprotect
Flag = True
With Sheets("Client Demos").ListObjects("Table3")
.Resize Range("$A$2:$W$" & LR)
Range("F" & LR - 1).Copy Destination:=Range("F" & LR)
Range("G" & LR - 1).Copy Destination:=Range("G" & LR)
Range("I" & LR - 1).Copy Destination:=Range("I" & LR)
Range("L" & LR - 1).Copy Destination:=Range("L" & LR)
Range("M" & LR - 1).Copy Destination:=Range("M" & LR)
Range("N" & LR - 1).Copy Destination:=Range("N" & LR)
Range("O" & LR - 1).Copy Destination:=Range("O" & LR)
Range("P" & LR - 1).Copy Destination:=Range("P" & LR)
Range("Q" & LR - 1).Copy Destination:=Range("Q" & LR)
Range("S" & LR - 1).Copy Destination:=Range("S" & LR)
Range("U" & LR - 1).Copy Destination:=Range("U" & LR)
Range("V" & LR - 1).Copy Destination:=Range("V" & LR)
Range("W" & LR - 1).Copy Destination:=Range("W" & LR)
End With
Flag = False
End If
End If
End Sub
This does exactly as it was intended to do on the other worksheet - it copies the contents from the row prior down to the new row. The problem is, unlike the worksheet for which this code was originally written, in which it was all formulas being copied down, this worksheet has lists/drop-downs being copied down, and as a result it is taking the actual value from the cell above and copying it into the new cell.
1) Is there a way to copy only the drop-down list from the cell above, and not the value?
2) If not, how would I modify the above code to clear the value of each cell after the drop-down list and value are copied down, without clearing the drop-down box?
Thank you in advance.
Adam
Bookmarks