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

[µo°Ý] ½Ð°Ý¦p¦óÅý¥X¨Óªº¤å¦r¤£¦PÃC¦â¤ÎÂà²Åé¦r©ÎªÌÁcÅé¦r

[µo°Ý] ½Ð°Ý¦p¦óÅý¥X¨Óªº¤å¦r¤£¦PÃC¦â¤ÎÂà²Åé¦r©ÎªÌÁcÅé¦r

Worksheets(customer).Cells(cnt, 10).Value =  "µo²¼ª÷ÃB¡GUSD" & Worksheets("Oracle").Cells(I, 18).Value & "          ½c¼Æ:" & Worksheets("Oracle").Cells(I, 41).Value & "               Âd¸¹:" & Split(Worksheets("Oracle").Cells(I, 42).Value, "/")(0) & "               ¥Øªº´ä¡G" & Worksheets("Oracle").Cells(I, 26).Value ¡¨

½Ð°Ý¡G
¦p¤WªºVBA, ¦pªG·Q¥X¨Óªº®ÄªG¬Y¨Ç¦r¦³ÃC¦â¡A¥i¥H¶Ü¡H
¤ñ¦p ¡G
"µo²¼ª÷ÃB¡GUSD" & Worksheets("Oracle").Cells(I, 18).Value & "  ³o¬qªº¤å¦r­n¬õ¦â
"               ¥Øªº´ä¡G" & Worksheets("Oracle").Cells(I, 26).Value ¡¨³o¬qªº¤å¦r­nÂŦâ

ÁÙ¦³¥i§_¥X¨Ó«á§â©Ò¦³¤å¥óÂà²Åé¦r©ÎªÌÁcÅé¦r¡H

  1. Sub SCHPN()
  2.   Dim I As Double
  3.   Dim cnt As Double
  4.   Dim customer As String
  5.   Dim A As String
  6.   Dim LastRec As Integer
  7.   Dim k As Integer
  8.   Dim j As Integer
  9.   Dim l As Integer
  10.   Dim m As Double
  11.   Dim z As Integer
  12.   Dim y As Integer
  13.   Dim e As Integer
  14.   Dim d As Integer
  15.   Dim f As Integer
  16.   Dim FRng As Range
  17.   Dim s1 As String, s2 As String, s3 As String
  18.   Dim wrdApp As Object

  19.   j = Worksheets("Oracle").Range("A" & Worksheets("Oracle").Rows.Count).End(xlUp).Row
  20.   l = Worksheets("Follower").Range("A" & Worksheets("Follower").Rows.Count).End(xlUp).Row
  21.   z = Worksheets("Rule").Range("B" & Worksheets("Rule").Rows.Count).End(xlUp).Row
  22.   y = 39
  23.   Do
  24.    Set wrdApp = CreateObject("Word.Document")

  25.     Application.ScreenUpdating = False
  26.   f = 0
  27.   d = 0
  28.   e = 0
  29.   cnt = 74  

  30.   A = Worksheets("Rule").Cells(y, 2).Value
  31.   customer = A
  32.   Worksheets("SchPN").Copy After:=Worksheets(Worksheets.Count)
  33.   Worksheets(Worksheets.Count).Name = customer
  34.   Worksheets(customer).Range("H5").Value = Date
  35. For I = 2 To j
  36.   If Worksheets("Oracle").Cells(I, 5).Value = customer And Worksheets("Oracle").Cells(I, 19).Value > 0 And Trim(Worksheets("Oracle").Cells(I, 19).Value) <> "" And Trim(Worksheets("Oracle").Cells(I, 15).Value) = "" And (Trim(Worksheets("Oracle").Cells(I, 20).Value) = Trim(Worksheets("Oracle").Cells(I, 18).Value) Or Trim(Worksheets("Oracle").Cells(I, 20).Value) = "") Then
  37.   If Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 1 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 2 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 3 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 4 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 5 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 6 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 7 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 8 Or Left((Worksheets("Oracle").Cells(I, 22).Value), 1) = 9 Then
  38.   Set FRng = Worksheets(customer).Range("A:A").Find(Worksheets("Oracle").Cells(I, 1).Value, lookat:=xlWhole, SearchDirection:=xlPrevious)
  39.   If InStr(UCase(Worksheets("Oracle").Cells(I, 2).MergeArea(1)), "SPOT") = 0 And InStr(UCase(Worksheets("Oracle").Cells(I, 2).MergeArea(1)), "³q内´µ现货") = 0 Then
  40.   If FRng Is Nothing Then
  41.   Worksheets(customer).Cells(cnt, 1).Value = Worksheets("Oracle").Cells(I, 1).Value
  42.   Worksheets(customer).Cells(cnt, 2).Value = Worksheets("Oracle").Cells(I, 24).Value
  43.   Worksheets(customer).Cells(cnt, 3).Value = Worksheets("Oracle").Cells(I, 14).Value
  44.   If IsError(Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:B"), 2, False)) Then Worksheets(customer).Cells(cnt, 8).Value = "«Ý³qª¾" Else If Trim(Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:B"), 2, False)) = "" Then Worksheets(customer).Cells(cnt, 8).Value = "«Ý³qª¾" Else Worksheets(customer).Cells(cnt, 8).Value = Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:B"), 2, False)
  45.   Worksheets(customer).Cells(cnt, 19).Value = Left((Worksheets("Oracle").Cells(I, 22).Value), 3)
  46.   Worksheets(customer).Cells(cnt, 9).Value = "USD" & Format(Worksheets("Oracle").Cells(I, 19).Value * Worksheets(customer).Cells(cnt, 19).Value, "#.00")
  47.   Worksheets(customer).Cells(cnt, 19).Value = ""
  48.   
  49.   If Left((Worksheets("Oracle").Cells(I, 1).Value), 1) = 8 Then
  50.     s1 = Left((Worksheets("Oracle").Cells(I, 22).Value), 3) & "©wª÷"
  51.     s2 = "          ¥N²z:" & Worksheets("Oracle").Cells(I, 10).Value
  52.     s3 = " ¬ü°ê "
  53.     S = s1 & "               ¦X¦Pª÷ÃB¡GUSD" & Worksheets("Oracle").Cells(I, 19).Value & "          ¥Øªº´ä¡G" & Worksheets("Oracle").Cells(I, 26).Value & s2 & s3
  54.     With Worksheets(customer).Cells(cnt, 10)
  55.     .Value = S
  56.     .Characters(InStr(S, s1), Len(s1)).Font.Color = vbRed
  57.     .Characters(InStr(S, s2), Len(s2)).Font.Color = -16777024
  58.     .Characters(InStr(S, s3), Len(s3)).Font.Color = vbBlue
  59.     .Value = T_S_Cvt(.Value, 1)
  60.     End With
  61.   End If
  62.   
  63.   If Left((Worksheets("Oracle").Cells(I, 1).Value), 1) = 2 Then
  64.     s1 = Left((Worksheets("Oracle").Cells(I, 22).Value), 3) & "©wª÷"
  65.     s2 = "          ¥N²z:" & Worksheets("Oracle").Cells(I, 10).Value
  66.     s3 = " ·ç¤h"
  67.     S = s1 & "               ¦X¦Pª÷ÃB¡GUSD" & Worksheets("Oracle").Cells(I, 19).Value & "          ¥Øªº´ä¡G" & Worksheets("Oracle").Cells(I, 26).Value & s2 & s3
  68.    With Worksheets(customer).Cells(cnt, 10)
  69.    .Value = S
  70.    .Characters(InStr(S, s1), Len(s1)).Font.Color = vbRed
  71.    .Characters(InStr(S, s2), Len(s2)).Font.Color = -16777024
  72.    .Characters(InStr(S, s3), Len(s3)).Font.Color = vbBlue
  73.    .Value = T_S_Cvt(.Value, 1)
  74.    End With
  75.   End If
  76.   
  77.   Worksheets(customer).Cells(cnt, 12).Value = Worksheets("Oracle").Cells(I, 19).Value
  78.   Worksheets(customer).Cells(cnt, 15).Value = Worksheets("Oracle").Cells(I, 22).Value
  79.   Worksheets(customer).Cells(cnt, 11).Value = Worksheets("Oracle").Cells(I, 15).Value
  80.   If IsError(Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:B"), 2, False)) Then Worksheets(customer).Cells(cnt, 13).Value = Worksheets("Oracle").Cells(I, 28).Value Else Worksheets(customer).Cells(cnt, 13).Value = Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:C"), 2, False)
  81.   Worksheets(customer).Cells(cnt, 14).Value = Worksheets("Oracle").Cells(I, 27).Value
  82.   If IsError(Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:B"), 2, False)) Then Worksheets(customer).Cells(cnt, 16).Value = "" Else Worksheets(customer).Cells(cnt, 16).Value = Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:Q"), 17, False)
  83.   If IsError(Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:B"), 2, False)) Then Worksheets(customer).Cells(cnt, 17).Value = "" Else Worksheets(customer).Cells(cnt, 17).Value = Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:E"), 5, False)
  84.   If IsError(Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:B"), 2, False)) Then Worksheets(customer).Cells(cnt, 18).Value = Worksheets("Oracle").Cells(I, 25).Value Else Worksheets(customer).Cells(cnt, 18).Value = Application.VLookup(Worksheets(customer).Cells(cnt, 1).Value, Sheets("State").Range("A:X"), 24, False)
  85.   Worksheets(customer).Cells(cnt, 19).Value = Worksheets("Oracle").Cells(I, 18).Value
  86.   If Trim(Worksheets("Oracle").Cells(I, 8).Value) = "" Then Worksheets(customer).Cells(cnt, 5).Value = "¨S¦³" Else Worksheets(customer).Cells(cnt, 5).Value = "¦³"
  87.   If Worksheets(customer).Cells(cnt, 5).Value = "¨S¦³" Then Worksheets(customer).Cells(cnt, 5).Font.Color = vbRed
  88.   Worksheets(customer).Cells(cnt, 4).Value = Worksheets("Oracle").Cells(I, 7).Value
  89.   Worksheets(customer).Cells(cnt, 6).Value = Worksheets("Oracle").Cells(I, 12).Value
  90.   If Trim(Worksheets("Oracle").Cells(I, 27).Value) = "" Then Worksheets(customer).Cells(cnt, 7).Value = "«Ý³qª¾" Else Worksheets(customer).Cells(cnt, 7).Value = Worksheets("Oracle").Cells(I, 27).Value
  91.   With Worksheets(customer).Range(Worksheets(customer).Cells(cnt, 1), Worksheets(customer).Cells(cnt, 10))

  92.         .Borders.LineStyle = 1

  93.         .Borders.LineStyle = 1

  94.         .Borders.ColorIndex = 0

  95.         .BorderAround , 2, 0

  96.     End With
  97.   cnt = cnt + 1
  98.   d = d + 1
  99.   e = e + 1
  100.     End If
  101.    End If
  102.     End If
  103.    End If
  104.     Next I
  105.   Loop Until y > z
  106. Application.ScreenUpdating = True

  107.     wrdApp.Close False
  108. End Sub
  109. Public Function T_S_Cvt(strData, bytOption) As String

  110.     With wrdApp

  111.         .Content = strData

  112.         ' ½Õ¥Î Word TCSCConverter ¤èªk¨ÓÂà´«Ác²Åé

  113.         .Range.TCSCConverter bytOption, True, True

  114.         T_S_Cvt = .Content

  115.     End With

  116. End Function
½Æ»s¥N½X
¦^´_ 3# c_c_lai

.content = strData ¥X²{RUN-TIME ERROR'424': Object required

TOP

¦^´_ 3# c_c_lai


    ©ú¥Õ¡A¤w¸g¸Ñ¨M¡AÁÂÁÂ

TOP

¦^´_ 9# c_c_lai


    §Úµo²{¥Î³o­Ó¤èªk¡A·|¦³­Ó°ÝÃD¥X¨Ó¡A´N¬O¤£Â_»s³y¤@¨ÇÁôÂêºword¡A¨C¦¸Ãö¾÷³£·|Åã¥Ü­n¤£­nÀx¦sword.

TOP

        ÀR«ä¦Û¦b : «H¤ß¡B¼Ý¤O¡B«i®ð¤TªÌ¨ã³Æ¡A«h¤Ñ¤U¨S¦³°µ¤£¦¨ªº¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD