###前提・実現したいこと
ExcelVBAでタスクをガントチャートで管理するシステムを作っています。
実装中に下図1のような結果になりました。
本来であれば、図2のようにチャートが重ならないように結果を反映させたいです。
###該当のソースコード
Private Sub ComboBox1_Change() End Sub Private Sub CommandButton1_Click() Dim i For i = 10 To 60 Step 10 ComboBox1.AddItem i & "分" Next End Sub Private Sub CommandButton2_Click() Cells.Select Selection.ColumnWidth = 2 If Cells(1, 1) = "" Then Worksheets("Task").Cells(1, 1).Value = TextBox1.Value Columns("A:E").AutoFit If ComboBox1.Text = "10分" Then Cells(1, 2).Interior.ColorIndex = 3 Cells(1, 2).Value = "□" ElseIf ComboBox1.Text = "20分" Then Range(Cells(1, 2), Cells(1, 3)).Interior.ColorIndex = 3 Range(Cells(1, 2), Cells(1, 3)).Value = "□" ElseIf ComboBox1.Text = "30分" Then Range(Cells(1, 2), Cells(1, 4)).Interior.ColorIndex = 3 Range(Cells(1, 2), Cells(1, 4)).Value = "□" ElseIf ComboBox1.Text = "40分" Then Range(Cells(1, 2), Cells(1, 5)).Interior.ColorIndex = 3 Range(Cells(1, 2), Cells(1, 5)).Value = "□" ElseIf ComboBox1.Text = "50分" Then Range(Cells(1, 2), Cells(1, 6)).Interior.ColorIndex = 3 Range(Cells(1, 2), Cells(1, 6)).Value = "□" ElseIf ComboBox1.Text = "60分" Then Range(Cells(1, 2), Cells(1, 7)).Interior.ColorIndex = 3 Range(Cells(1, 2), Cells(1, 7)).Value = "□" End If Else 'MsgBox Maxcol n = Cells(Rows.Count, 1).End(xlUp).Row + 1 m = Range("A" & n - 1).End(xlToRight).Column + 1 MsgBox m Worksheets("Task").Cells(n, 1).Value = TextBox1.Value Columns("A:E").AutoFit If ComboBox1.Text = "10分" Then Cells(n, m).Interior.ColorIndex = 3 'Range(n, m).Value = "□" Range(Cells(n, m), Cells(n, m)).Value = "□" ElseIf ComboBox1.Text = "20分" Then Range(Cells(n, m), Cells(n, m + 1)).Interior.ColorIndex = 3 Range(Cells(n, m), Cells(n, m + 1)).Value = "□" ElseIf ComboBox1.Text = "30分" Then Range(Cells(n, m), Cells(n, m + 2)).Interior.ColorIndex = 3 Range(Cells(n, m), Cells(n, m + 2)).Value = "□" ElseIf ComboBox1.Text = "40分" Then Range(Cells(n, m), Cells(n, m + 3)).Interior.ColorIndex = 3 Range(Cells(n, m), Cells(n, m + 3)).Value = "□" ElseIf ComboBox1.Text = "50分" Then Range(Cells(n, m), Cells(n, m + 4)).Interior.ColorIndex = 3 Range(Cells(n, m), Cells(n, m + 4)).Value = "□" ElseIf ComboBox1.Text = "60分" Then Range(Cells(n, m), Cells(n, m + 5)).Interior.ColorIndex = 3 Range(Cells(n, m), Cells(n, m + 5)).Value = "□" End If End If End Sub Private Sub Label2_Click() End Sub Private Sub TextBox1_Change() End Sub Private Sub UserForm_Click() End Sub Private Sub UserForm_Initialize() UserForm1.Show End Sub
###試したこと
一つ上の最終列に1を足した列番号から着色をスタートさせてみましたがうまくいきませんでした。
分かる方、ご教示お願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。