ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ListBox.ColumnWidths¦³¿ìªk³]©w¬°¦Û°ÊÄæ¼e¶Ü?

[µo°Ý] ListBox.ColumnWidths¦³¿ìªk³]©w¬°¦Û°ÊÄæ¼e¶Ü?

  1. Sub checkWashCar()
  2.    
  3.     Dim arr(), rng, i%, j%, m%
  4.     aaa = WorksheetFunction.CountA(Rows("1:1"))
  5.     Me.ListBox1.ColumnCount = aaa
  6.     Me.ListBox1.ColumnWidths = "60,100,60"
  7.    
  8.     rng = [a1].CurrentRegion
  9.     For i = 1 To UBound(rng)
  10.         If i = 1 Or rng(i, searchW) Like serchItem Then
  11.             m = m + 1
  12.             ReDim Preserve arr(1 To aaa, 1 To m)
  13.             For j = 1 To aaa
  14.                 arr(j, m) = rng(i, j)
  15.             Next
  16.         End If
  17.     Next
  18.     Me.ListBox1.List() = Application.Transpose(arr)

  19. End Sub
½Æ»s¥N½X
¹ê»Ú¤W§Úªº¦r¼Æ¦³¥i¯àÅܦh©Î¬OÅܤÖ,¦³¥i¯à¨Ì¾Ú¦r¼Æ¦Û°ÊÄæ¼e¶Ü?
¦Ó¤£­n¹³§Ú­ì¥»ªº¤è¦¡¤â°ÊÄæ¼e?
PKKO

¦^´_ 1# PKKO
ListBox¬OUserform¤WªºÁÙ¬O¤u§@ªí¤Wªº?
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 1# PKKO
°²³]¬O«üUserform¤WListBox¡A
¥i§Q¥Î¼È®ÉªºTextBox¨Ó§ä¥X¦UÄæ³Ì¤j¼e«×¦A³]©w
  1. Sub checkWashCar()
  2.   Dim arr(), rng, i%, j%, m%
  3.   aaa = WorksheetFunction.CountA(Rows("1:1"))
  4.   Me.ListBox1.ColumnCount = aaa
  5.   'Me.ListBox1.ColumnWidths = "60,100,60"
  6.   
  7.   rng = [a1].CurrentRegion
  8.   For i = 1 To UBound(rng)
  9.     If i = 1 Or rng(i, searchW) Like serchItem Then
  10.       m = m + 1
  11.       ReDim Preserve arr(1 To aaa, 1 To m)
  12.       For j = 1 To aaa
  13.         arr(j, m) = rng(i, j)
  14.       Next
  15.     End If
  16.   Next
  17.   Me.ListBox1.List = Application.Transpose(arr)

  18.   '·s¼W¥H¤Ucode
  19.   Dim sWidth As String, dTotal As Double
  20.   Dim oTemp As Object
  21.   
  22.   Set oTemp = Me.Controls.Add("Forms.TextBox.1")
  23.   With oTemp
  24.     .AutoSize = True
  25.     .MultiLine = True
  26.     .WordWrap = False
  27.     .SelectionMargin = False
  28.     .Font.Name = Me.ListBox1.Font.Name
  29.     .Font.Size = Me.ListBox1.Font.Size
  30.   End With
  31.   
  32.   For j = 0 To Me.ListBox1.ColumnCount - 1
  33.     oTemp.Text = ""
  34.     For i = 0 To Me.ListBox1.ListCount - 1
  35.       oTemp.Text = oTemp.Text & Me.ListBox1.List(i, j) & vbCr
  36.     Next
  37.     dTotal = dTotal + oTemp.Width
  38.     sWidth = sWidth & oTemp.Width & ";"
  39.   Next
  40.   Me.Controls.Remove oTemp.Name
  41.   Me.ListBox1.Width = dTotal + Me.ListBox1.ColumnCount + 5
  42.   Me.ListBox1.ColumnWidths = sWidth
  43. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 3# stillfish00

·PÁ¤j¤j,§¹¥þ¤F¸Ñ,­ì¨ÓÁÙ¦³³oºØ¤èªk,­ÉÃè¦A§âÃè¤l§R°£,·P®¦®@!!

¥t¥~ÁÙ·Q½Ð°Ý¤@¤U

¤@¡Blistbox¦³¿ìªk¦³¤À¹j½u¶Ü?(AÄæ»PBÄ椧¶¡¦³¤À¹j½u,©Î¬O²Ä¤@¦C»P²Ä¤G¦C¤¤¶¡¦³¤À¹j½u?)

¤G¡B§Ú¦b¬Ý¹L§O¤Hªºlistbox¥i¥H¿é¥X¦Üsheet¤º,Åܦ¨sheet1ªº¤º®e,­n¦p¦ó¿ì¨ì©O~?
PKKO

TOP

¦^´_ 3# stillfish00


    ¬°¦ó²Ä¤@¦¸·j´M,Äæ¼e³£·|¥¿±`Åã¥Ü,¦ý²Ä¤G¦¸·j´M,Äæ¼e´N¶]±¼¤F(Á`Äæ¼e),µLªk¥X²{¨÷¶b©¹¥kÃä²¾°Ê

    ¦ý¬O¥u­n°h¥XUSERFORM¦A­«·s·j´M¤@¦¸,³£·|¬O¥¿½Tªº,·j´M§¹¤£Ãö³¬USERFORM,¦b·j´M¤@¦¸³£·|¬O¿ùªº~?
PKKO

TOP

¦^´_ 4# PKKO
1.  ListBox ±±¨î¶µµL¤À¹j½u³]©w¡A¦³¿³½ì¥i§ä ListView ±±¨î¶µ¸Õ¸Õ
2.  ¿é¥X¨ì¤u§@ªí¡A¤£À´§A°ÝÃD¦b­þ¡A¤U­±code´N¯à²³æ°µ¨ì¤F
  1. Private Sub CommandButton2_Click()
  2.   Dim ar
  3.   
  4.   ar = Me.ListBox1.List
  5.   With Sheets(3).[A1].Resize(UBound(ar) + 1, UBound(ar, 2) + 1)
  6.     .Value = ar
  7.     .EntireColumn.AutoFit
  8.   End With
  9. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 5# PKKO
Me.ListBox1.Width = dTotal + Me.ListBox1.ColumnCount + 5
³o¦æ¬O½Õ¾ãÁ`¼e«×¡A­n©T©wÁ`¼e«×´N¤£­n¥[
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 7# stillfish00


    ·PÁ¤j¤j,§Ú¦A¸Õ¸Õ¬Ý!!
PKKO

TOP

¦^´_ 6# stillfish00


This is very nice code,thanks.
PKKO

TOP

        ÀR«ä¦Û¦b : ¤H¥Í³Ì¤jªº¦¨´N¬O±q¥¢±Ñ¤¤¯¸°_¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD