是否有人知道如何觸發文本以翻轉到下一個空白單元格,如果它設置爲vba。我有以下代碼正確設置值刪除重複值。我的首選是合併單元格以在可能的情況下顯示擴展值,但是由於數據在表格中,我無法做到這一點。Excel VBA - 當在VBA中設置值時,測試翻轉到下一個空白單元格
Public Sub GANT_TidyRow(ByVal argRow As Range, argDateTableRange As Range)
Dim lclLastValue As String
Dim lclFirstCell As Boolean
Dim lclCurrCell As Range
Dim lclCellRange As Range
Set argRow = argRow.Worksheet.Cells(argRow.Cells(1, 1).Row, argDateTableRange.Cells(1, 1).Column)
Set argRow = argRow.Resize(1, argDateTableRange.Columns.Count)
lclFirstCell = True
For Each lclCurrCell In argRow
If lclCurrCell.Value = lclLastValue And Not lclFirstCell Then
lclCurrCell.Value = ""
Set lclCellRange = lclCellRange.Resize(1, lclCellRange.Columns.Count + 1)
Else
If Not lclFirstCell Then
Call GANT_SetBorders(lclCellRange.Borders, _
xlNone, _
xlSingle, vbBlack)
End If
Set lclCellRange = lclCurrCell
lclFirstCell = False
lclLastValue = lclCurrCell.Value
End If
Next lclCurrCell
End Sub
下面是一個屏幕截圖,前2行已在vba中更新,以將下列單元格設置爲空白。我在Excel中手動更新的最後一行清除該值,然後將前一個單元格翻轉到下一個單元格。如果是這樣的話,請讓我知道這可能是一個更常見和準確的術語。 由於代表數量不足,我無法發佈圖片,但這是我拍攝的屏幕截圖。 http://imgur.com/Ti8InmL
當你說「文本翻轉到下一個空白單元格」時,你是說你想要空白單元格的值與上面行中的單元格的值相同嗎? – Cyril
你可以顯示你的工作表的圖像? –
如果你的意圖是合併單元格然後看[this](https://stackoverflow.com/questions/44387798/excel-vba-merging-a-range-inside-a-loop/44414146#44414146) –