OOobbs2/45
質問
先日はご回答ありがとうございました。 今回もお知恵を貸してください。 下図の様に「A1」は項目名で「A2」から名前が入力してあります。
この状態からマクロを実行すると、 『重複のデータ(行)は削除される。』 という下記の結果を導き出したいです。
現在、下記の様なマクロを設定しています。 Sub main Dim oDoc As Object Dim oSheet As Object Dim oSheets As Object Dim oColumn As Object Dim oEmptyRange As Object Dim oLastRange As Object Dim nNum As Long oDoc = ThisComponent oSheets = oDoc.getSheets() oSheet = oSheets.getByIndex(0) oColumn = oSheet.getColumns().getByName("A") oEmptyRanges = oColumn.queryEmptyCells() nNum = oEmptyRanges.getCount() oLastRange = oEmptyRanges.getByIndex(nNum -1) oCell = oLastRange.getCellByPosition(0,1) rwIndex = 1 oeach = oSheet.getCellByPosition(0, rwIndex +1) Do While rwIndex < oCell.CellAddress.Row If oSheet.getCellByPosition(0, rwIndex).String = oeach.String Then oSheet.Rows.removeByIndex(rwIndex, 1) Else rwIndex = rwIndex +1 End If Loop msgbox("完了") End sub これを実行すると、
という必要なデータも削除されてしまいます。 「If〜Else」のループが上手く機能していないのでしょうか。 宜しくお願いします。 回答
感想,コメント,メモ
|