重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

EXCEL(エクセル)で、シート上の0.01以上の数字が一つもない列をすべて、VBAなどを使って自動で削除にする方法を教えていただけないでしょうか。
 よろしくお願いいたします。

A 回答 (2件)

失礼しました



Sub Macro1_2()
 
  iMaxRow = Cells.SpecialCells(xlLastCell).Row
  iMaxClm = Cells.SpecialCells(xlLastCell).Column

  For Clm = iMaxClm To 1 Step -1
    bClmDel = True
    For Row = 1 To iMaxRow Step 1
      If (IsNumeric(Cells(Row, Clm).Value)) Then
        If (Cells(Row, Clm).Value >= 0.01) Then
          bClmDel = False
          Exit For
        End If
      End If
    Next Row
  
    If bClmDel Then
      Columns(Clm).Delete Shift:=xlToLeft
    End If
  Next Clm
End Sub
    • good
    • 0
この回答へのお礼

ありがとうございます。いままでの苦労がなくなりました。

お礼日時:2006/09/12 17:43

Sub Macro1()


  
  iMaxRow = Cells.SpecialCells(xlLastCell).Row
  iMaxClm = Cells.SpecialCells(xlLastCell).Column

  For Clm = iMaxClm To 1 Step -1
    bClmDel = True
    For Row = 1 To iMaxRow Step 1
      If (Cells(Row, Clm) >= 0.01) Then
        bClmDel = False
        Exit For
      End If
    Next Row
    
    If bClmDel Then
      Columns(Clm).Delete Shift:=xlToLeft
    End If
  Next Clm
End Sub

この回答への補足

ご回答にあるマクロですと、列に文字列があった場合、削除ができないのですが、この問題を解決することはできないでしょうか。

補足日時:2006/09/11 14:39
    • good
    • 0
この回答へのお礼

ありがとうございました。

お礼日時:2006/09/11 11:25

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!