¨â²Õ¼ÆÈ¥h°£«½Æªº¸ê®Æ«á±Æ§Ç
- ©«¤l
- 17
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 71
- ÂI¦W
- 1
- §@·~¨t²Î
- window
- ³nÅ骩¥»
- google
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-6-27
- ³Ì«áµn¿ý
- 2024-5-17
|
¨â²Õ¼ÆÈ¥h°£«½Æªº¸ê®Æ«á±Æ§Ç
¥»©«³Ì«á¥Ñ henry860608 ©ó 2023-3-19 20:31 ½s¿è
¤wª¾A¡BB¨â¦C¦³¨â²Õ¼ÆÈ¡A·Qn³z¹L¤½¦¡±N¨â²Õ¼ÆȦ³«½Æªº³¡¤À¥h°£¡A¨Ã±N¸ê®Æ¨Ì¼ÆȤj¤p±Æ§Ç(¦p¤U±C¦C)
A B
1 1
3 4
6 7
9 9
12 10
15 14
18 16
21 18
24 22
27 37
30 46
33 57
36 80
C
1
3
4
6
7
9
10
12
14
15
16
18
21
22
24
27
30
33
36
37
46
57
80 |
|
|
|
|
|
|
- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-3-20 12:04 ½s¿è
[attach]35988[/attach]¦^´_ 1# henry860608
ÁÂÁ«e½úµoªí¦¹¥DÃD»P±¡¹Ò
«á¾Ç½m²ß°}¦C»P¦r¨åªº¸Ñ¨M¤è®×¦p¤U,½Ð«e½ú°Ñ¦Ò
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim Brr, Y, C%, R&
'¡ô«Å§iÅܼÆ:(Brr,Y)¬O³q¥Î«¬ÅܼÆ,C¬Oµu¾ã¼Æ,R¬Oªø¾ã¼Æ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OY³o³q¥Î«¬ÅܼƬO ¦r¨å
[C:C].ClearContents
'¡ô¥OCÄæÀx¦s®æ¤º®e²M°£
Brr = Range([B1], Cells(Rows.Count, "A").End(3))
'¡ô¥OBrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,
'¥H[B1]¨ìAÄæ³Ì«á¦³¤º®eÀx¦s®æȱa¤J
For C = 1 To 2
'¡ô³]¶¶°j°é!C±q1¨ì 2
For R = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!R±q1¨ì Brr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
Y(Brr(R, C)) = ""
'¡ô¥OR°j°é¦CR°j°éÄæBrr°}¦CÈ·íkey,item¬OªÅ¦r¤¸,¯Ç¤JY¦r¨å¸Ì
'Ykey«½Æ¥u¯d¤@µ§
Next
Next
With [C1].Resize(Y.Count, 1)
'¡ô¥H¤U¬OÃö©ó[C1]Àx¦s®æÂX®i¦V¤U(Y¦r¨åkey¼Æ¶q)¦Cªº¬ÛÃöµ{§Ç
.Value = Application.Transpose(Y.Keys)
'¡ô¥OÀx¦s®æÈ¥H Y¦r¨åkeyÂà¸m«áȱa¤J
.Sort KEY1:=.Item(1), Order1:=1, _
Header:=0, Orientation:=1
'¡ô¥O¥H[C1]§@¬°±Æ§Ç°ò·Ç°µ¤@¼h¦¸µL¼ÐÃD¦CªºÁa¦V¶¶±Æ§Ç
End With
Erase Brr: Set Y = Nothing
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y
|
|
|
|
|
- ©«¤l
- 1387
- ¥DÃD
- 4
- ºëµØ
- 0
- ¿n¤À
- 1397
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN
- ³nÅ骩¥»
- 2007
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2015-9-11
- ³Ì«áµn¿ý
- 2024-11-5
|
|
google"EXCEL°g" blog ©Îgoogleºô§}:https://hcm19522.blogspot.com/
|
|
|
|
|
- ©«¤l
- 354
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 387
- ÂI¦W
- 0
- §@·~¨t²Î
- windows7
- ³nÅ骩¥»
- vba,vb,excel2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-1-8
- ³Ì«áµn¿ý
- 2024-8-2
|
¦^´_ 3# hcm19522
Sub ¥h«±Æ§Ç()
With CreateObject("adodb.connection"): V = Application.Version
If V >= 12 Then V = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0; "
If V < 12 Then V = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0; "
.Open V & "Data Source=" & ThisWorkbook.FullName
Set s = Sheets("¤u§@ªí1")
s.Columns(4).ClearContents
s.Rows("1:1").Insert Shift:=xlDown
s.Range("a1:b1") = Array("a", "b")
q = "select a as a from [¤u§@ªí1$A1:A] " & vbCrLf & " union all "
q = q & vbCrLf & " select b as a from [¤u§@ªí1$B1:B]"
q = "select distinct a from (" & q & ") order by a "
s.Range("d2").CopyFromRecordset .Execute(q)
s.Rows("1:1").Delete: End With
End Sub |
|
|
|
|
|
|
- ©«¤l
- 17
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 71
- ÂI¦W
- 1
- §@·~¨t²Î
- window
- ³nÅ骩¥»
- google
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-6-27
- ³Ì«áµn¿ý
- 2024-5-17
|
¦n³á ·PÁ¤j¤j¼ö±¡¤À¨É ±ßÂI´N¨Ó¸Õ¸Õ¬Ý |
|
|
|
|
|
|
- ©«¤l
- 154
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 200
- ÂI¦W
- 28
- §@·~¨t²Î
- windwos 7
- ³nÅ骩¥»
- 64bit
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2017-5-29
- ³Ì«áµn¿ý
- 2024-10-22
|
¦^´_ 1# henry860608
Sub test()
Dim arr As Object, brr As Variant
Set arr = CreateObject("System.Collections.ArrayList")
brr = Range("A1:B" & Cells(Rows.Count, "A").End(xlUp).Row)
For Each n In brr
If n <> vbNullString And Not arr.contains(n) Then arr.Add (n)
Next
arr.Sort
Range("c1:c" & arr.Count) = Application.Transpose(arr.toarray)
End Sub |
|
|
|
|
|
|
- ©«¤l
- 17
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 71
- ÂI¦W
- 1
- §@·~¨t²Î
- window
- ³nÅ骩¥»
- google
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-6-27
- ³Ì«áµn¿ý
- 2024-5-17
|
¦^´_ 4# singo1232001
¤£¦n·N«ä¤j¤j¡A¥i¥H°Ý¤@¤U³o¥|¦æ¬O¬Æ»ò·N«ä?
¤p§Ì¹ïSQL¯AÂy²LÁ¡- q = "select a as a from [¤u§@ªí1$A1:A] " & vbCrLf & " union all "
- q = q & vbCrLf & " select b as a from [¤u§@ªí1$B1:B]"
- q = "select distinct a from (" & q & ") order by a "
- s.Range("d2").CopyFromRecordset .Execute(q)
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¦^´_ 6# quickfixer
ÁÂÁ«e½ú
³o¤èªk¨S¦³±Nȼg¤JÀx¦s®æ´N¥i±Æ§Ç,Y¥Î©ó¦Ûqªí³æ¤¤²M³æ©ú²Óªº¦¬¶°¤£«½Æ«á±Æ§Ç,¦n¹³«Ü¤è«K |
|
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y
|
|
|
|
|
- ©«¤l
- 154
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 200
- ÂI¦W
- 28
- §@·~¨t²Î
- windwos 7
- ³nÅ骩¥»
- 64bit
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2017-5-29
- ³Ì«áµn¿ý
- 2024-10-22
|
¦^´_ 8# Andy2483
¨Ò¦pactivex combobox
Sheets("¤u§@ªí1").ComboBox1.List = arr.toarray
Sheets("¤u§@ªí1").ComboBox1.ListIndex = 0
|
|
|
|
|
|
|
- ©«¤l
- 354
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 387
- ÂI¦W
- 0
- §@·~¨t²Î
- windows7
- ³nÅ骩¥»
- vba,vb,excel2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-1-8
- ³Ì«áµn¿ý
- 2024-8-2
|
¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-3-21 23:16 ½s¿è
¦^´_ 7# henry860608
ÕY¨S¾Ç¹LSQL ¥i¥Hª½±µ¸õ¹L ¨Ï¥Î¨ä¥L¤j¤jªº¸Ñªk¤ñ¸û¤è«K ¾Ç²ß¸ô½u¤]¤ñ¸û¥¿³W
¥t¥~¨Ï¥Î¦¹¤èªk³£»Ýn¦w¸Ë .Framework 3.5
¥]¬Aq¤jªºarraylist
¥H¤U¸ÑÄÀqȤ¤,SQL»yªk¸ÑÄÀ
select distinct a from
(select a as a from [¤u§@ªí1$A1:A]
union all
select b as a from [¤u§@ªí1$B1:B] )
order by a
1.
Àò¨ú¤u§@ªí1¤¤ªºAÄæ¸ê®Æ
select a as a from [¤u§@ªí1$A1:A]
¦X¨Ö
union all
¤u§@ªí1¤¤ªºBÄæ¸ê®Æ
select b as a from [¤u§@ªí1$B1:B]
2.
select distinct a from '±N1.³¡¤ÀÀò¨ú¾ã²z¦nªº¸ê®Æ distinct¥h«
(select a as a from [¤u§@ªí1$A1:A]
union all
select b as a from [¤u§@ªí1$B1:B] )
order by a '¨Ã¥Border by±Æ§Ç
Y§A¹ïSQL¦³¿³½ì ±q2019¦~«á,§K¶Oºô¸ô½Òµ{«D±`¦h ¤×¨äB¯¸¤W ±q¹s¶}©l¾Ç ¤j·§2~3Ó¤ë´N¥i¥H
¯u¥¿·N¸q¤W¨Ã¤£¬O®³¨Óµ¹excel³æ¿W¥Îªº
¥u¤£¹Lè¦n¥i¥H®³vba°V½m»yªk ¹ê»Ú¥Î¦bSQL server »Pvba¤W
±¹ï²{¹êªº°ªt²ü³õ´º,¶W¹L30000µ§¥H¤Wªº¸ê®Æ ©ÎªÌ¦hªí¾ã¦X ´N¬OSQLªº¸nªù
¤×¨ä¦b¤ººô¤¤ ¦h¥x¹q¸£ ¶i¾P¦s ©ÎªÌ±µª¦ÂΤW³£¦³«Ü±j¤jªº«K§Q©Ê ¦Ó¥B¤£¥Î¾á¤ß ¸ê®Æ½s½X²§±` ¤ñ¦p"温" "羣" ³oÃþexcel ·|²§±`ªº¤å¦r
·íµM¥¼¨Ó¤]¯à¹B¥Î¨ìptSQL ©ÎªÌMySQL |
|
|
|
|
|
|