Board logo

¼ÐÃD: ´M§ä¦³¨S¦³¬Û¦P¼Æ¾ÚªºÄæ¦ì [¥´¦L¥»­¶]

§@ªÌ: 198188    ®É¶¡: 2024-2-27 15:36     ¼ÐÃD: ´M§ä¦³¨S¦³¬Û¦P¼Æ¾ÚªºÄæ¦ì

Data ªíªº¸ê®Æ¨ÓŪ¨ú Invoice ªíªº¸ê®Æ, ¥ý§ä´MData ªí©Ò¦³Ä榳¨S¦³¸òInvoice ªíÀx¦s®æG5 ¬Û¦Pªº¡C

¦pªG¦³¡A¦b¸ÓÄæ¾Þ§@¤U­±¡G
Dataªí ÄæA ¹ï¤ñ  Invoiceªí ÄæC
Dataªí ÄæB ¹ï¤ñ  Invoiceªí ÄæD
Dataªí ÄæC ¹ï¤ñ  Invoiceªí ÄæE
¤T¼Ë³£¬Û¦P¡AŪ¨ú Invoice ªí ÄæF ªº¼Æ­È¨ìData ªí¸òInvoice G5 ªíÀx¦s®æ¬Û¦Pªº¸ÓÄæ¦ì

¦pªG¨S¦³¡A¦b³Ì«á¤@Äæ¾Þ§@¤U­±¡G
Dataªí ÄæA ¹ï¤ñ  Invoiceªí ÄæC
Dataªí ÄæB ¹ï¤ñ  Invoiceªí ÄæD
Dataªí ÄæC ¹ï¤ñ  Invoiceªí ÄæE
¤T¼Ë³£¬Û¦P¡AŪ¨ú Invoice ªí ÄæF ªº¼Æ­È¨ìData ªí³Ì«á¤@Äæ

DataªíÄæE ­pºâ: DataªíÄæD ´î DataªíÄæF ¶}©l¨ì³Ì«á¦³¼Æ­Èªº¤@Äæ

¦pªGInvoice ªí ÄæC - E²Õ¦X¦bData ªíÄæA - C ¨S¦³§ä¨ìªº¶µ¥Ø¡A¼u¥Xµøµ¡¦C¥X³o¨Ç²Õ¦X
§@ªÌ: Andy2483    ®É¶¡: 2024-2-27 16:32

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-2-27 16:41 ½s¿è

¦^´_ 1# 198188

ÁÂÁ«e½úµoªí¦¹¥DÃD»P½d¨Ò
«á¾Ç¤ù¬q¾Ç²ß¤è®×¦p¤U,½Ð«e½ú°Ñ¦Ò

Option Explicit
'¦¹¬q¬O §ä´MData ªí©Ò¦³Ä榳¸òInvoice ªíÀx¦s®æG5 ¬Û¦Pªº,
'¤T¼Ë³£¬Û¦P¡AŪ¨ú Invoice ªí ÄæF ªº¼Æ­È¨ìData ªí¸òInvoice G5 ªíÀx¦s®æ¬Û¦Pªº¸ÓÄæ¦ì

Sub TEST()
Dim Brr, Z, i&, c, T$, T1$, T2$, T3$
c = Application.Match([Invoice!G5], [Data!1:1], 0)
Set Z = CreateObject("Scripting.Dictionary")
If IsError(c) Then MsgBox "§ä¤£¨ìG5ÃöÁä¦r": Exit Sub
Brr = Range([Invoice!F12], [Invoice!C65536].End(3))
For i = 1 To UBound(Brr)
   T1 = Trim(Brr(i, 1)): T2 = Val(Brr(i, 2)): T3 = Val(Brr(i, 3)): T = T1 & "/" & T2 & "/" & T3
   If T1 = "" Then GoTo i01
   Z(T) = Val(Brr(i, 4))
i01: Next
Brr = [Data!A1].CurrentRegion
For i = 2 To UBound(Brr)
   T1 = Trim(Brr(i, 1)): T2 = Val(Brr(i, 2)): T3 = Val(Brr(i, 3)): T = T1 & "/" & T2 & "/" & T3
   If T1 = "" Or Z(T) = "" Then Brr(i - 1, 1) = "": GoTo i02
   Brr(i - 1, 1) = Z(T)
i02: Next
[Data!A1].Item(2, c).Resize(UBound(Brr) - 1) = Brr
End Sub
§@ªÌ: 198188    ®É¶¡: 2024-2-27 16:41

¦^´_ 2# Andy2483


    ¦pªG§ä¤£¨ìG5, À³¸Ó§â©Ò¦³°Ñ¼Æ¾É¤J¨ì³Ì«á¤@¦æ¡A¤£¬OÅã¥Ü¡§§ä¤£¨ìG5ªº°Ñ¼Æ¡¨
§@ªÌ: Andy2483    ®É¶¡: 2024-2-27 16:42

¦^´_ 3# 198188

½Ð«e½ú¦Û¤v¥ý¸Õ¸Õ¬Ý
§@ªÌ: 198188    ®É¶¡: 2024-2-27 16:45

¦^´_ 4# Andy2483


    ¯à¤£¯à§iª¾«ç¼Ë§ä³Ì«á¤@Äæ¡A§Ú¥uÀ´±o§ä³Ì«á¤@¦æ¡C
¥t¥~³Ì«á¦³­Ó­pºâ¡AÄæD ´î¥h ÄæF ¨ì³Ì«á¤@¦æ¡A³o¥yÀ³¸Ó¦p¦ó¼g¡H
§@ªÌ: 198188    ®É¶¡: 2024-2-28 10:35

¦^´_ 4# Andy2483

§Ú­×§ï¤F¦p¤U¡Aº¡¨¬¤F©Ò¦³­n¨D¡C

Option Explicit
Sub TEST3()
Dim Brr, Z, i&, c, T$, T1$, T2$, T3$, a, b, d
Dim ColNum As Long
c = Application.Match([Invoice!G5], [Data!1:1], 0)

If IsError(c) Then
ColNum = Worksheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column
Worksheets("Data").Cells(1, ColNum + 1) = Worksheets("Invoice").Cells(5, 7)
End If

c = Application.Match([Invoice!G5], [Data!1:1], 0)
Set Z = CreateObject("Scripting.Dictionary")

Brr = Range([Invoice!F10], [Invoice!C65536].End(3))
For i = 1 To UBound(Brr)
   T1 = Trim(Brr(i, 1)): T2 = Val(Brr(i, 2)): T3 = Val(Brr(i, 3)): T = T1 & "/" & T2 & "/" & T3
   If T1 = "" Then GoTo i01
   Z(T) = Val(Brr(i, 4))
i01: Next
Brr = [Data!A1].CurrentRegion
For i = 2 To UBound(Brr)
   T1 = Trim(Brr(i, 1)): T2 = Val(Brr(i, 2)): T3 = Val(Brr(i, 3)): T = T1 & "/" & T2 & "/" & T3
   If T1 = "" Or Z(T) = "" Then Brr(i - 1, 1) = "": GoTo i02
   Brr(i - 1, 1) = Z(T)
i02: Next
[Data!A1].Item(2, c).Resize(UBound(Brr) - 1) = Brr

a = Worksheets("Data").Range("A1").End(xlDown).Row
d = Worksheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column
For i = 2 To a
Worksheets("Data").Cells(i, 5) = Worksheets("Data").Cells(i, 4) - Application.WorksheetFunction.Sum(Worksheets("Data").Range(Cells(i, 6), Cells(i, d + 1)))
Next i

End Sub
§@ªÌ: ­ã´£³¡ªL    ®É¶¡: 2024-2-28 11:31

¦³«h¨O´«·s, µL«h·s¼W//

[attach]37520[/attach]
§@ªÌ: 198188    ®É¶¡: 2024-2-28 13:12

¦^´_ 7# ­ã´£³¡ªL

¦pªG¦³­«½Æ¡A³o­Ó¦³¨S¦³¦Û°Ê¥[Á`¼Æ¶q¡H
§@ªÌ: ­ã´£³¡ªL    ®É¶¡: 2024-2-28 17:50

¦^´_ 8# 198188


invioce ­Y¦³­«ÂÐ, ·|¥[Á`,
ª`·N:dataªí¬O­«·s¶×Á`, ªº·|¥ý²M°£
§@ªÌ: 198188    ®É¶¡: 2024-2-28 17:58

¦^´_ 9# ­ã´£³¡ªL

´ú¸Õ¹L¡Aªº½T¥i¥H¡C
½Ð°Ý¥i§_³Ì«á¥[¤@­Ó¥\¯à¡A´£¿ôINVOICE ¦³­þ¨Ç¦bDATA §ä¤£¨ìªº©Ò¦³¶µ¥Ø¡C
¥i¥H¥Î顔¦âhighlight³o¨Ç¶µ¥Ø ©ÎªÌ¼u­Óµøµ¡Åã¥Ü³o¨Çªº©ú²Ó
§@ªÌ: 198188    ®É¶¡: 2024-2-28 18:18

¦^´_ 9# ­ã´£³¡ªL


­ã¤j¡A§Ú¥´¶}ùØ­±µ{¦¡·Q¾Ç²ß¤Î°µ·L½Õ¡A¦ý¬OùØ­±ª`ÄÀ¬O¶Ã½X¡A¥i§_±Nµ{¦¡¶K¦b¦^´_¤W¡A¤è«K§Ú¾Ç²ß¡AÁÂÁ¡I
§@ªÌ: Andy2483    ®É¶¡: 2024-2-29 08:03

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-2-29 10:55 ½s¿è

ÁÂÁ½׾Â,ÁÂÁ ­ã´£³¡ªL«e½ú«ü¾É,ÁÂÁ«e½úµo¸ÜÃD¤@°_¾Ç²ß
«Øij«e½ú¦b±o¨ì¨ó§U¥N½X«á¸ÕµÛ¦Û¤v³v¦C¤F¸Ñ¨ä·N¸q,¥²­n®É¦Û¤vµù¸Ñ,¤£¤F¸Ñªº³¡¤À¬d½×¾Â,©Î¥¦ºô,©Î°Ý¥N½X²Ó¸`
¥H¤U¬O ­ã´£³¡ªL«e½úªº¤è®×

Sub Test_A1()
Dim Arr, Brr, xD, xZ As Range, xF As Range, T$, R&, C&, i&
T = [Invoice!G5] '³æ¸¹
If Not T Like "INV########" Then Exit Sub '³æ¸¹¤£²Å¦XINV+8¦ì¤é´Á..¸õ¥X
Set xZ = [Data!a1].Cells(1, Columns.Count).End(1)  '§ädata²Ä¤@¦æ³Ì«á«DªÅ
Set xF = [Data!1:1].Find(T, Lookat:=xlWhole) '§ä³æ¸¹¦bdataªºÄæ¦ì
If xF Is Nothing Then Set xZ = xZ(1, 2): Set xF = xZ '­Y³æ¸¹¤£¦s¦b, ¼W¥[¤@Äæ
Set xD = CreateObject("Scripting.Dictionary")
'-------------------------------
Arr = Range([Data!c1], [Data!a1].Cells(Rows.Count, 1).End(3))
Arr(1, 1) = T '±NArr²Ä¤@Äæ­º®æ©ñ¤J"³æ¸¹"
For i = 2 To UBound(Arr)
    T = Arr(i, 1) & "\" & Arr(i, 2) & "\" & Arr(i, 3)
    xD(T) = i '¦r¨å°O¾Ð¦æ¦ì¸m
    Arr(i, 1) = 0  '±NArr²Ä¤@Äæ©ñ¤J0, ¥H³Æ¶ñ¤J¼Æ¶q
Next i
'----------------------------
Brr = Range([Invoice!h1], [Invoice!a1].Cells(Rows.Count, 1).End(3))
For i = 2 To UBound(Brr)
    R = xD(Brr(i, 3) & "\" & Brr(i, 4) & "\" & Brr(i, 5))
    If R > 0 Then Arr(R, 1) = Arr(R, 1) + Brr(i, 6)
Next i
'----------------------------
xF.Resize(UBound(Arr)).Value = Arr
With Range([Data!F1], xZ).Resize(UBound(Arr)) '³æ¸¹Äæ®æ¦¡
     .ColumnWidth = 15 '²Î¤@Äæ¼e
     .Borders.LineStyle = 1 '¥[®Ø
     .HorizontalAlignment = xlCenter 'Áa¸m¤¤
     .VerticalAlignment = xlCenter   '¾î¸m¤¤
End With
[Data!e2].Resize(UBound(Arr) - 1) = "=D2-SUM(F2:" & xZ(2).Address(0, 0) & ")" 'EÄæ"µ²¾l"¤½¦¡(ÀHÄæ¼ÆÅܤÆ)..§R¥hÄæ¤]¥i¥¿½T­pºâ
End Sub
§@ªÌ: 198188    ®É¶¡: 2024-2-29 10:43

¦^´_ 12# Andy2483


­ì¥»¬OKH ªº¼Æ¶qcopy ¨ìData ªºÄæD, ¦pªG·Q±NÄæD §ï爲ÄæE¡A ³o­ÓÀ³¸Ó¦b­þ¥y­×§ï¡H
§@ªÌ: 198188    ®É¶¡: 2024-2-29 11:07

¦^´_ 13# 198188

§ä¨ì¤èªk¤F

    Sub Test_A1()
Dim Arr, Brr, xD, xZ As Range, xF As Range, T$, R&, C&, i&, A, B

A = Worksheets("Data").Range("A1").End(xlDown).Row
For B = 2 To A
Worksheets("Data").Cells(B, 4) = Worksheets("Data").Cells(B, 5)
Next B

T = [data!E1] 'invoice no
Set xZ = [Data!a1].Cells(1, Columns.Count).End(1)  'Find Data last column
Set xF = [Data!1:1].Find(T, Lookat:=xlWhole) 'Find invoice no from Data all column?
If xF Is Nothing Then Set xZ = xZ(1, 2): Set xF = xZ 'if don't find, add one column


Set xD = CreateObject("Scripting.Dictionary")
'-------------------------------
Arr = Range([Data!c1], [Data!a1].Cells(Rows.Count, 1).End(3))
Arr(1, 1) = T 'put Arr first column on invoice
For i = 2 To UBound(Arr)
    T = Arr(i, 1) & "\" & Arr(i, 2) & "\" & Arr(i, 3)
    xD(T) = i 'record column place
    Arr(i, 1) = 0  'set Arr first column 0,for back up to input?
Next i
'----------------------------
Brr = Range([KH!E1], [KH!a1].Cells(Rows.Count, 1).End(3))
For i = 2 To UBound(Brr)
    R = xD(Brr(i, 2) & "\" & Brr(i, 3) & "\" & Brr(i, 4))
    If R > 0 Then Arr(R, 1) = Arr(R, 1) + Brr(i, 5)
Next i
'----------------------------
xF.Resize(UBound(Arr)).Value = Arr

[Data!F2].Resize(UBound(Arr) - 1) = "=E2-SUM(G2:" & xZ(2).Address(0, 0) & ")" 'Column E BAL.
'RESET AND DELETE OLD RECORD
End Sub
§@ªÌ: Andy2483    ®É¶¡: 2024-2-29 11:13

¦^´_ 13# 198188


    ³o¸ÜÃD½d¨Ò¨S¦³³o»Ý¨D,«Øij¥t¤W¶Ç·s½d¨Ò,¸Ì­±©ñ¨â­Óµ²ªGªí(°õ¦æ«eªí,°õ¦æµ²ªGªí),
³o¼Ëªº½d¨ÒÅý¨ó§UªÌ¤ñ¸û¨â­Óµ²ªGªíªº®t²§,«Ü®e©öª¾¹D»Ý¨D¬O¤°»ò
§@ªÌ: 198188    ®É¶¡: 2024-2-29 12:56

¦^´_ 15# Andy2483


   ¦]爲§Ú­×§ï¤F¤@¨Ç®æ¦¡¡A©Ò¥H»Ý­n¦A·L½Õµ{¦¡¡C
ªþ¥ó¤W§Ú°ò©ó¤@¨Ç¹ê»Ú§ïÅܦӰµ¤F¤@¨Ç§ï°Ê¡Aµ{¦¡¤]·L½Õ¤F¡C




Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)