Page 1 of 1

รบกวนสอบถามคำสั่ง IF Then else VBA ครับ

Posted: Tue Apr 17, 2018 4:28 pm
by arxyang
ผมต้องการเทียบค่าข้อมูลระหว่างสองตัวแปร เช่น A<=500 and b<=1 ให้แสดงผลออกมาเป็นค่าเช่น 200 ต้องเขียนประมาณไหนครับ
ขอบคุณครับ

Re: รบกวนสอบถามคำสั่ง IF Then else VBA ครับ

Posted: Tue Apr 17, 2018 4:38 pm
by puriwutpokin
คำถามเกี่ยว VBA ตามกฏของบอร์ดนี้ ต้องเขียนมาก่อนครับ ติดขัดตรงไหน มาถามต่อครับ เบื้องต้นลองศึกษาจาก Google หรือ You Tube แล้วติดตรงไหนมาถามกันในบอร์ดนี้ครับ

Re: รบกวนสอบถามคำสั่ง IF Then else VBA ครับ

Posted: Wed Apr 18, 2018 9:27 am
by arxyang
puriwutpokin wrote: Tue Apr 17, 2018 4:38 pm คำถามเกี่ยว VBA ตามกฏของบอร์ดนี้ ต้องเขียนมาก่อนครับ ติดขัดตรงไหน มาถามต่อครับ เบื้องต้นลองศึกษาจาก Google หรือ You Tube แล้วติดตรงไหนมาถามกันในบอร์ดนี้ครับ
Option Explicit

Function Shippingprice(S) As String
Dim W As String
Dim P As String

if P<=500 && W<=1.00
then S = "205"
else if P<=1000 and W<=1.00
thenS = "266"
else if P<=1500 and W<=1.00
thenS = "327"
else if P<=2000 and W<=1.00
thenS = "388"
else if P<=2500 and W<=1.00
thenS = "450"
else if P<=3000 and W<=1.00
thenS = "511"
else if P<=3500 and W<=1.00
thenS = "572"
else if P<=4000 and W<=1.00
thenS = "634"
else if P<=4500 and W<=1.00
thenS = "695"
else if P<=5000 and W<=1.00
thenS = "756"
else if P<=5500 and W<=1.00
thenS = "817"
else if P<=6000 and W<=1.00
thenS = "879"
else if P<=6500 and W<=1.00
thenS = "940"
else if P<=7000 and W<=1.00
thenS = "1001"
else if P<=7500 and W<=1.00
thenS = "1062"
else if P<=8000 and W<=1.00
thenS = "1124"
else if P<=8500 and W<=1.00
thenS = "1185"
else if P<=9000 and W<=1.00
thenS = "1246"
else if P<=9500 and W<=1.00
thenS = "1307"
else if P<=10000 and W<=1.00
thenS = "1369"



End If
End Function

ประมานนี้ครับ

Re: รบกวนสอบถามคำสั่ง IF Then else VBA ครับ

Posted: Wed Apr 18, 2018 9:51 am
by logic
แนบเป็นไฟล์เอ็กเซลมาด้วยจะดีกว่าเพื่อน ๆ จะได้ช่วยกันดูให้ได้ แต่ก็ต้องบอกมาด้วยว่าต้องการคำตอบแสดงที่ไหน

ข้อความที่เป็นโค้ดให้ทำตามกฎการใช้บอร์ดข้อ 5 ด้านบนของหน้านี้ครับ

Re: รบกวนสอบถามคำสั่ง IF Then else VBA ครับ

Posted: Wed Apr 18, 2018 9:50 pm
by puriwutpokin
ลองดูการใช้ คำสั่ง​เบื้องต้นของ อ.คนควน ดูครับ wordpress/if-then-else/
ติดขัดอย่างไร ก็ทำตามที่คุณLogic
แนะนำ​ครับ