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

·Q½Ð°Ýexcel¯à¨C¤Ñ§ì¥~¸ê´Á³fªº¸ê®Æ¶Ü

¥H¤Uªºµ{¦¡½X¥i¥H§ó·s
§A¥i¥H¦h¹Á¸Õ¬Ý¬Ý
§Ú¥u§ì¨ú´Á¥æ©Òºô¯¸ªº¸ê®Æ¡A¦Ó´Á¥æ©Ò¦b¥æ©ö¤é¦¬½L«á¤U¤È¤TÂI§ó·s¸ê®Æ
  1. Sub ¥x«ü´ÁOI¸ê®Æ¤@()
  2. '================================================================================================================================
  3. Dim MyUrl As String
  4. '================================================================================================================================
  5. Application.ScreenUpdating = False  '¥[§Ö³B²z³t«×

  6. Worksheets("Temp").Select          '¼È¦s¸ê®Æªººô­¶

  7. Cells.Clear

  8. MyUrl = "URL;http://www.taifex.com.tw/chinese/3/3_1_1.asp"

  9.     With ActiveSheet.QueryTables.Add(Connection:=MyUrl, Destination:=Range("A1"))
  10.         .FieldNames = True
  11.         .RowNumbers = False
  12.         .FillAdjacentFormulas = False
  13.         .PreserveFormatting = True
  14.         .RefreshOnFileOpen = False
  15.         .BackgroundQuery = True
  16.         .RefreshStyle = xlInsertDeleteCells
  17.         .SavePassword = False
  18.         .SaveData = True
  19.         .AdjustColumnWidth = True
  20.         .RefreshPeriod = 0
  21.         .WebSelectionType = xlEntirePage
  22.         .WebFormatting = xlWebFormattingNone
  23.         .WebPreFormattedTextToColumns = True
  24.         .WebConsecutiveDelimitersAsOne = True
  25.         .WebSingleBlockTextImport = False
  26.         .WebDisableDateRecognition = False
  27.         .WebDisableRedirections = False
  28.         .Refresh BackgroundQuery:=False
  29.     End With
  30. '--------------------------------------------------------------------------
  31.    
  32. Bye:
  33. '--------------------------------------------------------------------------
  34. Delete_Rows
  35. '--------------------------------------------------------------------------
  36. End Sub

  37. Private Function Delete_Rows()
  38. '==========================================================================
  39. Dim Temp_Count As Integer
  40. Dim Key_Point As String
  41. Dim Data_Row As Integer
  42. Dim Delete_Row As Integer
  43. Dim I As Integer
  44. '==========================================================================
  45. Temp_Count = Worksheets("Temp").Range("A65536").End(xlUp).Row
  46. '--------------------------------------------------------------------------

  47. StepA:
  48. '--------------------------------------------------------------------------
  49. '§ä¥XÃöÁä¦r¤¸¡A§PÂ_©Ò»Ý¸ê®ÆªºÄæ¦ì
  50. '--------------------------------------------------------------------------
  51. For I = 1 To Temp_Count

  52.     Key_Point = Worksheets("Temp").Range("A" & I).Value

  53.     If Key_Point = "»OªÑ´Á³f (TX) ¦æ±¡ªí" Then
  54.    
  55.         Data_Row = I
  56.         
  57.         GoTo StepB
  58.         
  59.     End If
  60.    
  61. Next I
  62. '--------------------------------------------------------------------------

  63. StepB:
  64. '--------------------------------------------------------------------------
  65. '§R°£¤£¥²­nªº¸ê®Æ
  66. '--------------------------------------------------------------------------
  67. Delete_Row = Data_Row - 3

  68. Rows("1:" & Delete_Row).Select

  69. Selection.Delete Shift:=xlUp
  70. '--------------------------------------------------------------------------
  71. End Function
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¸Ü¦h¤£¦p¸Ü¤Ö¡A¸Ü¤Ö¤£¦p¸Ü¦n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD