หาส่วนต่างของคะแนนF1กับF2


0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

01 ต.ค. 66 , 15:09:18
อ่าน 349 ครั้ง

SakDa

หาส่วนต่างของคะแนนF1กับF2
« เมื่อ: 01 ต.ค. 66 , 15:09:18 »
อยากทราบสูตรในการหาความต่างของคะแนนก่อนกลางภาค กับ หลังกลางภาค ดูว่ารายการไหนมีมากมีน้อย
field
group--scorezone ------fullscore
---21F--------1---------------100
---21F--------2---------------50
...
ผลลัพธ์คือ (1-2) 100-50 = 50
ตอนนี้ทำแบบส่งออกเซลแล้วก็ลบเอาครับ ถ้าได้รับคำตอบมาก็จะเก็บไว้ใช้คราหน้าต่อ
ขอบคุณครับ  รบกวนส่งออกไฟล์เป็น mdb ให้ก่อนครับ

 

01 ต.ค. 66 , 21:14:46
ตอบกลับ #1

SakDa

: หาส่วนต่างของคะแนนF1กับF2
« ตอบกลับ #1 เมื่อ: 01 ต.ค. 66 , 21:14:46 »
คล้ายๆของเอ็กเซลแนวนี้เลยครับ แบบนี้เลยครับ ผมลองใช้คำค้นดู ......... แต่ผมก็ไม่สามารถทำอะไรกับแนวโค้ดเหล่านี้ครับ เผื่อผู้รู้แวะมาตอบครับ ขณะที่รอคำตอบ ก็ลองค้น ด้วยคำว่าตัดสต๊อก เราต้องสร้างตารางเก็บแต่ละค่าไว้ ว่า ตารางนี้เก็บ F1 ตารางนี้เก็บ F2 โดยมีตัวอ้างอิงคือ กลุ่มเรียน/ชั้นเรียน
Is there an easy way to subtract one row from another row but only if there is data. For example a2-a3 to z2-z3 etc. Only if those fields are populated.
Thanks,
Greg

Logic: If A2 and A3 is not blank, then subtract A2 minus A3.
Code:
Sub myMacro()
     Dim myArray(1, 25) As Long
     myArray(0, 0) = Range("A2").Value
     myArray(1, 0) = Range("A3").Value
     myArray(0, 1) = Range("B2").Value
     myArray(1, 1) = Range("B3").Value
     myArray(0, 2) = Range("C2").Value
     myArray(1, 2) = Range("C3").Value
     myArray(0, 3) = Range("D2").Value
     myArray(1, 3) = Range("D3").Value
     'Continue here and add all the ranges to the array.
     i = 0
     Do Until i > 25
          value1 = myArray(0, i)
          value2 = myArray(1, i)
          myResult = myFunction(value1, value2)
          MsgBox myResult
          i = i + 1
     Loop
End Sub

Function myFunction(value1, value2)
     If value1 <> "" _
     And value2 <> "" Then
          myFunction = value1 - value2
          Exit Function
     End If
     myFunction = ""
End Function

doogis

Thanks for the reply. Is there something I can do with a "range" command? If my data is not static and is >25 then I have to change the code.
My data looks like this,


#4
Code:
Sub myMacro()
     c = 1
     lc = Cells(1, Columns.Count).End(xlToLeft).Column
     Do Until c > lc
          Cells(3, c).Value = myFunction(Cells(2, c).Value, Cells(3, c).Value)
          c = c + 1
     Loop
End Sub
Function myFunction(value1, value2)
     If value1 <> "" _
     And value2 <> "" Then
          myFunction = value1 - value2
          Exit Function
     End If
     myFunction = ""
End Function

 

03 ต.ค. 66 , 08:49:34
ตอบกลับ #2

nonc31

: หาส่วนต่างของคะแนนF1กับF2
« ตอบกลับ #2 เมื่อ: 03 ต.ค. 66 , 08:49:34 »
สร้างคิวรี่แบบแท็บไขว้  แล้วเอาคิวรี่ที่ได้  สร้างคิวรี่อีกคิวรี่หนึ่ง

 
โพสต์นี้ได้รับคำขอบคุณจาก: SakDa

03 ต.ค. 66 , 18:17:45
ตอบกลับ #3

SakDa

: หาส่วนต่างของคะแนนF1กับF2
« ตอบกลับ #3 เมื่อ: 03 ต.ค. 66 , 18:17:45 »
ขอบคุณครับ... ผมจะนำไปปรับใช้ ผมได้แก้ไขปัญหาขณะรอคำตอบคือ สร้างคิวรีเพื่อสร้างตาราง F1 สร้างตาราง F2 ทุกครั้งมีการเก็บคะแนนใหม่ แล้วก็ใช้คิวรี่ สองตัวมาลบกันอีกทีครับ โดยมี กลุ่มเรียนเป็นตัวเชื่อม

 


บอร์ดเรียนรู้ Access สำหรับคนไทย


 

Sitemap 1 2 3 4 5