Results 1 to 4 of 4

Copy list contents down, then clear contents

Threaded View

hektisk Copy list contents down, then... 04-07-2011, 01:58 PM
jaslake Re: Copy list contents down,... 04-07-2011, 02:23 PM
hektisk Re: Copy list contents down,... 04-07-2011, 04:30 PM
jaslake Re: Copy list contents down,... 04-07-2011, 04:34 PM
  1. #1
    Registered User
    Join Date
    01-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    87

    Copy list contents down, then clear contents

    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
    Last edited by hektisk; 04-07-2011 at 04:30 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1