Sub test() Dim myData As Variant 'Worksheets("Sheet3").Activate 'myData = Worksheets("Sheet3").Range(Cells(2, 1), Cells(11, 7)).Value 冗長な気がしたので↓に変更 myData = Worksheets("Sheet3").Range("A2:H11").Value 'Worksheets("Sheet1").Activate With Worksheets("Sheet1").ListBox1 .Left = 480 .Height = 300 .Width = 500 .ColumnCount = 7 .ColumnWidths = "25;70;100;25;25;25;25" .List = myData End With End Sub |
Sub test0() Worksheets("Sheet1").Activate With Worksheets("Sheet1").ListBox1 .Clear End With End Sub |
Sub test2() '選択項目をテキストボックスに表示 Worksheets("Sheet1").Activate With Worksheets("Sheet1").ListBox1 Worksheets("Sheet1").TextBox1 = .List(.ListIndex, 0) Worksheets("Sheet1").TextBox2 = .List(.ListIndex, 1) Worksheets("Sheet1").TextBox3 = .List(.ListIndex, 2) Worksheets("Sheet1").TextBox4 = .List(.ListIndex, 3) Worksheets("Sheet1").TextBox5 = .List(.ListIndex, 4) Worksheets("Sheet1").TextBox6 = .List(.ListIndex, 5) Worksheets("Sheet1").TextBox7 = .List(.ListIndex, 6) End With End Sub |
Sub test4() 'テキストボックスからリストボックスへ転記 Worksheets("Sheet1").Activate With Worksheets("Sheet1").ListBox1 .List(.ListIndex, 0) = Worksheets("Sheet1").TextBox1.Value .List(.ListIndex, 1) = Worksheets("Sheet1").TextBox2.Value .List(.ListIndex, 2) = Worksheets("Sheet1").TextBox3.Value .List(.ListIndex, 3) = Worksheets("Sheet1").TextBox4.Value .List(.ListIndex, 4) = Worksheets("Sheet1").TextBox5.Value .List(.ListIndex, 5) = Worksheets("Sheet1").TextBox6.Value .List(.ListIndex, 6) = Worksheets("Sheet1").TextBox7.Value End With End Sub |
Sub test3() 'テキストボックスをシートに転記 Dim myRow As Long Worksheets("Sheet1").Activate With Worksheets("Sheet3") myRow = Worksheets("Sheet1").ListBox1.ListIndex + 2 .Cells(myRow, 1).Value = Worksheets("Sheet1").TextBox1.Value .Cells(myRow, 2).Value = Worksheets("Sheet1").TextBox2.Value .Cells(myRow, 3).Value = Worksheets("Sheet1").TextBox3.Value .Cells(myRow, 4).Value = Worksheets("Sheet1").TextBox4.Value .Cells(myRow, 5).Value = Worksheets("Sheet1").TextBox5.Value .Cells(myRow, 6).Value = Worksheets("Sheet1").TextBox6.Value .Cells(myRow, 7).Value = Worksheets("Sheet1").TextBox7.Value End With Worksheets("Sheet3").Activate End Sub |
Sub test5() 'リストボックスからシート1へ転記 Dim myData As Variant Worksheets("Sheet1").Activate With Worksheets("Sheet1").ListBox1 myData = .List Worksheets("Sheet1").Range(Cells(5, 1), Cells(5 + .ListCount - 1, 7)).Value = myData End With End Sub |
スポンサードリンク