Excel dropdown to entire column

╄→尐↘猪︶ㄣ 提交于 2020-02-08 07:12:28

问题


How to copy a dropdown menu (data validation) to entire column in Excel (only rows that having something else too). And, in this case, how to leave row for the header?


回答1:


To copy and paste only the dropdown list (validation), and only to not empty cells, do the following:

  1. Select every possible cell (including empty ones) where you want to have the dropdown menu pasted.

  2. Hit F5, then Special..., finally Constants radio button and OK. This will select only cells which are not empty from your previous selection.

  3. Home > Paste > Paste Special...

  4. Validation radio button and lastly OK.

Let me know if it helps!




回答2:


Ok, I found the answer and now it's working:

Sub pasteCellToColumn()
    Dim lastRow As Long, i As Long

    lastRow = Sheets("Sheet1").Cells(Rows.Count, 2).End(xlUp).Row
    Sheets("hiddenData").Range("A1").Copy

    For i = 1 To lastRow
        If Len(Trim(Sheets("Sheet1").Range("A" & i).Value)) <> 0 Then
        Sheets("Sheet1").Range("K" & i).PasteSpecial _
        Paste:=xlPasteValidation
        End If
    Next i

End Sub



回答3:


  1. Select the entire column you want to validate
  2. Click on "Data Validation" from the Data tab

  3. Choose "List" from the "Allow" box

  4. Click on the arrow to the right of the "Source" box and select the cells containing the allowed values

And you are good to go!

More on that here.



来源:https://stackoverflow.com/questions/29059999/excel-dropdown-to-entire-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!