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

¤Wºô§ìªÑ²¼¸ê®Æ

¤Wºô§ìªÑ²¼¸ê®Æ

½Ð±Ð¦U¦ì¤j¤j:
¦³­ÓVBAµ{¦¡¸ê®Æ§ì¤£¤U¨Ó
½Ð¦U¦ì¤j¤jÀ°¦£¬d¬Ý­þ¸Ì¦³°ÝÃD
ÁÂÁÂ
Private Sub CommandButton1_Click()
Dim po As Integer        '«Å§iPO¬°¾ã¼Æ

lR = Range("A2").End(xlDown).Row
Rows(lR + 1 & ":400").Select       'aÄæªÅ¥Õ¥H¤U¥þ§R°£
Selection.Delete shift:=xlUp


LRA = Range("C2").End(xlDown).Row
For i = 3 To LRA
If Cells(i, 5) <> "" Then
ValueSno = "$A$" & i
Linkss = "URL;https://tw.stock.yahoo.com/q/q?s=" & Cells(i, 1)
        
po = lR - 5 + (7 * (i - 2)) '©w§ì¨ú¸ê®Æªí®æ°j°é
With ActiveSheet.QueryTables.Add(Connection:= _
Linkss, Destination:=Sheets("¤u§@ªí1").Range("b" & po))
      .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "6"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
        .Name = .ResultRange.Cells(3, 1)
    End With   
Range("A" & po + 2) = Cells(i, 1)
Cells(i, 2) = "=vlookup(" & Cells(i, 1) & ",$A$16:$0$200,2,0)"
Cells(i, 2) = Mid(Cells(i, 2), 5)
Cells(i, 7) = "=vlookup(" & Cells(i, 1) & ",$A$16:$0$200,4,0)"
End If
Next

End Sub
michael

¦^´_ 1# chairles59

ActiveSheet =Sheets("¤u§@ªí1") ¬O¶Ü?
  1. With ActiveSheet.QueryTables.Add(Connection:= _
  2. Linkss, Destination:=Sheets("¤u§@ªí1").Range("b" & po))
½Æ»s¥N½X
­×§ï¬Ý¬Ý
  1. With ActiveSheet.QueryTables.Add(Connection:= _
  2. Linkss, Destination:=ActiveSheet.Range("b" & po))
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE
·PÁ¤j¤j©âªÅÀ°§Ú¬Ý
¦ý¬O¦n¹³¤]¨S¦³¿ìªk§ì¤U¸ê®Æ
ªþ­ÓÀ£ÁYÀɦA³Â·Ð¤j¤jÀ°§Ú¬Ý¤@¤U

ªÑ²¼.rar (12 KB)

michael

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-3-6 15:05 ½s¿è

¦^´_ 3# chairles59

Rows(lR + 1 & ":400").Clear    'ª½±µ²M°£Àx¦s®æ,¤£¥²Select¦A§R°£
If Cells(I, 3) <> "" Then   'ªþÀÉ ¤u§@ªíCÄæ ,¨S¦³¶R¶i¤é´Á,©Ò¥H¤£·|°õ¦æ¶×¤J¸ê®Æªºµ{¦¡½X
Cells(I, 2) = "=vlookup(" & Cells(I, 1) & ",$A$16:$O$200,2,0)" ¬O­^¤å¦r¥ÀO,¤£¬O¼Æ¦r0
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

ª©¥D:
¤£³Ó·PÁª©¥D¤£Â_ªºÀ°§Ú­×§ï
¦ý¬O§Ú¥u§ì¤U²Ä¤@­ÓªÑ²¼´N¥d¦b
Cells(i, 2) = Mid(Cells(i, 2), 5)
¥¦Åã¥Ü
°õ¦æ¶¥¬q¿ù»~'13
«¬ºA¤£²Å
¯à§_½Ðª©¥D¦bÀ°§Ú¬Ý¤@¤U¨º¸ÌÁÙ¦³°ÝÃD
ÁÂÁÂ
michael

TOP

¦^´_ 5# chairles59
§A¸Õ¸Õ
  1. Sub »ù¦ì§ó·s()
  2.     Application.ScreenUpdating = False
  3.     Sheets(1).Activate
  4.     rc = Cells(Rows.Count, 1).End(xlUp).Row
  5.     For i = 3 To rc
  6.         Range("r1:az10").ClearContents
  7.         sn = Cells(i, 1)
  8.         With ActiveSheet.QueryTables.Add(Connection:="URL;https://tw.stock.yahoo.com/q/q?s=" & sn, Destination:=Range("$s$1"))
  9.             .WebFormatting = xlWebFormattingNone
  10.             .WebTables = "4,7"
  11.             .Refresh BackgroundQuery:=False
  12.             .Delete
  13.         End With
  14.         Range("b1") = Left(Range("w1"), 10)
  15.         Cells(i, 10) = Range("t5")
  16.         Cells(i, 9) = Range("u5")
  17.     Next
  18.     Range("r1:az10").ClearContents
  19.     Range("a1").Select
  20.     Application.ScreenUpdating = True
  21. End Sub
½Æ»s¥N½X
ªÑ²¼.zip (18.68 KB)

TOP

¦^´_ 5# chairles59
¯÷±N GBKEE ª©¤jµ¹§Aªº´£¥Ü¾ã²z¨Ãµy¥[­×¥¿¡A
¨ä¹ê GBKEE ª©¤j¤w¸g«ü¤Þ¥X§Aªº°ÝÃD©Ò¦b¡C
  1. Sub Ex()
  2.     Dim po As Integer                  '  «Å§i PO ¬°¾ã¼Æ
  3.    
  4.     lR = Range("A2").End(xlDown).Row      '  R = 9 : Variant/Long
  5.     Rows(lR + 1 & ":400").Clear                    '  ª½±µ²M°£Àx¦s®æ,¤£¥² Select ¦A§R°£
  6.     '  Selection.Delete shift:=xlUp
  7.    
  8.     LRA = Range("B2").End(xlDown).Row  '  LRA = 9 : Variant/Long

  9.     For i = 3 To LRA
  10.         '  If Cells(i, 3) <> "" Then    ' ¤u§@ªí C Äæ ,¨S¦³¶R¶i¤é´Á,©Ò¥H¤£·|°õ¦æ¶×¤J¸ê®Æªºµ{¦¡½X
  11.         If Cells(i, 3) = "" Then        ' ­×¥¿¬°ªÅ­È®É©l¶i¦æ¸ê®Æ¶×¤J
  12.             Valuesno = "$A$" & i
  13.             Linkss = "URL;https://tw.stock.yahoo.com/q/q?s=" & Cells(i, 1)
  14.         
  15.             po = lR - 5 + (7 * (i - 2)) '  ©w§ì¨ú¸ê®Æªí®æ°j°é

  16.             With ActiveSheet.QueryTables.Add(Connection:= _
  17.                                 Linkss, Destination:=ActiveSheet.Range("B" & po))
  18.                 .FieldNames = True
  19.                 .RowNumbers = False
  20.                 .FillAdjacentFormulas = False
  21.                 .PreserveFormatting = True
  22.                 .RefreshOnFileOpen = False
  23.                 .BackgroundQuery = True
  24.                 .RefreshStyle = xlInsertDeleteCells
  25.                 .SavePassword = False
  26.                 .SaveData = True
  27.                 .AdjustColumnWidth = True
  28.                 .RefreshPeriod = 0
  29.                 .WebSelectionType = xlSpecifiedTables
  30.                 .WebFormatting = xlWebFormattingNone
  31.                 .WebTables = "6"
  32.                 .WebPreFormattedTextToColumns = True
  33.                 .WebConsecutiveDelimitersAsOne = True
  34.                 .WebSingleBlockTextImport = False
  35.                 .WebDisableDateRecognition = False
  36.                 .WebDisableRedirections = False
  37.                 .Refresh BackgroundQuery:=False
  38.                 .Name = .ResultRange.Cells(3, 1)
  39.             End With
  40.             
  41.             Range("A" & po + 2) = Cells(i, 1)
  42.             '  Cells(i, 2) = "=vlookup(" & Cells(i, 1) & ",$A$16:$O$200,2,0)"    '  ¬O­^¤å¦r¥À O,¤£¬O¼Æ¦r 0
  43.             Cells(i, 2) = "=vlookup(" & Cells(i, 1) & ",$A$11:$O$200,2,0)"       '  ±q $A$16 °_©l¤§½d³ò·|³y¦¨ B3 ±o¥X¤£¥¿½T­È
  44.             Cells(i, 2) = Mid(Cells(i, 2).Text, 5)                               '  Mid(Cells(i, 2), 5) ·|²£¥Í°õ¦æ¶¥¬q¿ù»~ 13 «¬ºA¤£²Å
  45.             
  46.             '  Cells(i, 7) = "=vlookup(" & Cells(i, 1) & ",$A$16:$O$200,4,0)"    '  ¬O­^¤å¦r¥À O,¤£¬O¼Æ¦r 0
  47.             Cells(i, 7) = "=vlookup(" & Cells(i, 1) & ",$A$11:$O$200,4,0)"       '  ±q $A$16 °_©l¤§½d³ò·|³y¦¨ G3 ±o¥X¤£¥¿½T­È
  48.         End If
  49.     Next
  50. End Sub
½Æ»s¥N½X

TOP

¦^´_ 5# chairles59

TOP

¦^´_ 9# c_c_lai

c_c_lai¤j¤j :
·PÁÂ¥X¤â«ü¾É
¦]¬O·s¤â­n®ø¤Æ»Ý­n¤@ÂI®É¶¡
¸g¹L­×§ï
²{¦b¶]°_¨Ó¥i¥H¤F
¦p¦³ÁÙ°ÝÃD
½Ð¤j¤jÀ°¦£
ÁÂÁ¦U¦ì¤j¤j
michael

TOP

        ÀR«ä¦Û¦b : ¹ï¤÷¥À­nª¾®¦¡A·P®¦¡B³ø®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD