簡體   English   中英

如何取消合並帶有下拉列表的單元格並獲取帶有下拉列表的單元格?

[英]How to unmerge cell with drop-down list and get cells with drop-down list?

我正在嘗試取消合並帶有下拉列表的單元格,然后獲取帶有下拉列表的單元格。

期望的行為:

C1、C2 和 C3 單元格應該有一個下拉列表。

在此處輸入圖像描述

我試過了,但這只會將下拉列表保留在第一個單元格中

For Each cell In ThisWorkbook.ActiveSheet.UsedRange
    If cell.MergeCells Then
        Set joinedCells = cell.MergeArea
        cell.MergeCells = False
        joinedCells.Value = cell.Value
    End If
Next

我更喜歡Range.Fill而不是Range.CopyRange.PasteSpecial xlPasteValidation ,但 Scott Craner 的建議也有效。

Sub Temp()
    Dim Cell As Range
    Dim JoinedCells As Range
    For Each Cell In ThisWorkbook.ActiveSheet.UsedRange
        If Cell.MergeCells Then
            Set JoinedCells = Cell.MergeArea
            Cell.MergeCells = False
            JoinedCells.FillDown
        End If
    Next
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM