-1

在庫管理用のエクセル文書を作成しようとしています。「毎日の売上」と「配送」が追加され、シートが更新された在庫を維持し、収入と純利益を計算するワークブックを既に作成しています。これはすべて従来の Excel で行われます。ただし、このシートにはいくつかの問題があります。つまり、シートを自分で複製し、将来的には毎月変更する必要があります (私はアフリカの僻地にいて、人々はコンピューターに精通していないため、インターフェースは非常に複雑でなければなりません)。単純)。

私は最近 VBA マクロを発見し、このシートに書き込んでいます。これまでのところ、月と年のドロップダウン メニューを持つユーザー フォームを作成しました。Enter キーを押すと、プログラムは「マスター」ドキュメントを複製し、上部に日付を自動入力し、ワークブックを入力月と年として保存します。私の質問は次のとおりです。新しいワークブックの最後の列を削除するにはどうすればよいですか? マスターシートには31列ありますが、すべての月が31日というわけではないので、あとに続く「合計」列は削除せずに、不要な列を削除したいです。ドキュメントをフォーマットしたら、そのインベントリ シートの最後の列から前月のデータをインポートしたいと考えています。

これは私が苦労しているコードの一部です。翌月の最初の数日で自動的に入力される余分な列を削除できるようにしたい。たとえば、28-Feb-16、1-Mar-16、2-Mar-16、プログラムは 3 月の日付を検索し、関連する列を削除します。

Private Sub CmdEnter_Click()
    'Duplicate Sheet
    Sheets(Array("Daily Sales", "Total Inventory", "Deliveries",_
      "Income Statement", "Profits")).Copy
    'Fill Dates in Daily Sales
    Sheets("Daily Sales").Activate
    'Enter combo boxes into first cell
    Range("B6").Select
    ActiveCell = CDate("1-" & CmboMonth.Value & "-" &_
      CmboYear.Value)
    'Fill in Month Dates
    Selection.AutoFill Destination:=Range("B6:AF6"), _
    Type:=xlFillValues
    'Auto-Size Columns
    Cells.Select
    Cells.EntireColumn.AutoFit
    '
     'Fill Dates in Total Inventory
    Sheets("Total Inventory").Activate
    'Enter combo boxes into first cell
    Range("C5").Select
    ActiveCell = CDate("1-" & CmboMonth.Value & "-" &_
      CmboYear.Value)
    'Fill in Month Dates
    Selection.AutoFill Destination:=Range("C5:AG5"),_
      Type:=xlFillValues
    'Auto-Size Columns
    Cells.Select
    Cells.EntireColumn.AutoFit
    '
     'Fill Dates in Deliveries
    Sheets("Deliveries").Activate
    'Enter combo boxes into first cell
    Range("B6").Select
    ActiveCell = CDate("1-" & CmboMonth.Value & "-" &_
      CmboYear.Value)
    'Fill in Month Dates
    Selection.AutoFill Destination:=Range("B6:AF6"),_
       Type:=xlFillValues
    'Auto-Size Columns
    Cells.Select
    Cells.EntireColumn.AutoFit
    '
     'Fill Dates in Income Statement
    Sheets("Income Statement").Activate
    'Enter combo boxes into first cell
    Range("C4").Select
    ActiveCell = CDate("1-" & CmboMonth.Value & "-" &_
      CmboYear.Value)
    'Fill in Month Dates
    Selection.AutoFill Destination:=Range("C4:AG4"),_
      Type:=xlFillValues
    'Auto-Size Columns
    Cells.Select
    Cells.EntireColumn.AutoFit
    '
     'Fill Dates in Profits
    Sheets("Profits").Activate
    'Enter combo boxes into first cell
    Range("E4").Select
    ActiveCell = CDate("1-" & CmboMonth.Value & "-" &_
      CmboYear.Value)
    'Fill in Month Dates
    Selection.AutoFill Destination:=Range("E4:AI4"),_
      Type:=xlFillValues
    'Auto-Size Columns
    Cells.Select
    Cells.EntireColumn.AutoFit
    'Save As
    ActiveWorkbook.SaveAs Filename:= _
      "Macintosh HD:Users:meringue90:Desktop:" & CmboMonth.Value &_
     CmboYear.Value , FileFormat:= _
    xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub

これが理にかなっていることを願っています。また、私は VBA の初心者であることも指摘しておく必要があります。

4

2 に答える 2