Tue 20 Jun 2006 15:34:28
ส่วนช่องD1เป็นคำตอบของ A1+B1คำตอบจะอยู่ในช่องD1
ทีนี้ ช่องD1นี้ผมได้ใส่สูตร=IF(SUM(A1:B1)=C1,SUM(A1:B1),"#FF0000") นี้ลงไป
อธิบายสูตรคือ ถ้าช่องD1 ได้คำตอบ ไม่เท่ากับ ช่อง C1 ให้ช่องD1เป็นสีแดง(#FF0000)
แต่สูตรที่เขียนมันไม่ได้สีแดงนะครับ (ผมใส่ตัวนี้ลงไปแต่ไม่ได้ครับ#FF0000) มีวิธีแก้ให้ช่องมันเป็นสีแดงไหมครับ
รบกวนด้วยนะครับ
ขอบคุณมากครับ
แต่ผมมีวิธีการทำได้เหมือนกันคือ เลือกที่ Cell D1 แล้วไปที่ Format > Condition Formatting
เปลี่ยนค่าจาก Cell value is เป็น Formular is ส่วนในฟังก์ชั่นก็ใส่ =SUM($A$1:$B$1)<>C1
แล้วคลิ๊กที่ปุ่ม Format เลือกสีที่ต้องการ สามารถใช้งานได้เหมือนกันครับ
Wed 21 Jun 2006 08:22:28
โทษนะครับ ปัญหาคือ มันก๊อบลงมาใช้กับสูตร แถวอื่นๆไม่ได้นะครับ เพราะจะเอามาทำเป็นพัน แถวเลยนะครับ
รบกวนดูให้ทีครับ
ขอบคุณมากครับ
Wed 21 Jun 2006 08:29:05
โทษนะครับ จากสูตรที่ให้มานี้ผมได้ไปลองทำแล้วมันไม่มีอะไรเกิดขึ้นเลยนะครับ
มีสูตร ที่ทำให้ตาราง เป็นสีไหมครับ โดยเขียนเป็นสูตรเลยนะครับ ผมจะลองเอามาประยุกดูนะครับ
รบกวนดูให้ทีครับ
ขอบคุณมากครับ
ที่ Sheet tab คลิ๊กขวาเลือก View Code ครับ จะเปิดหน้าต่าง VBA ของ Sheet ขึ้นมา
เขียน Procedure ตามนี้ครับ
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
For i = 1 To 1000
If Cells(i, 1) <> "" And Cells(i, 2) <> "" And Cells(i, 3) <> "" And (Cells(i, 1) + Cells(i, 2)) <> Cells(i, 3) Then
Cells(i, 4).Interior.ColorIndex = 3 'รหัสสีแดงมีค่าเป็น 3
Else
Cells(i, 4).Interior.ColorIndex = 0 'ไม่มีสีรหัสมีค่าเป็น 0
End If
Next i
Application.EnableEvents = True
End Sub
Procedure นี้จะทำการตรวจจับความเปลี่ยนแปลงใน column A, B, C ว่ามีข้อมูลหรือไม่ ถ้ามีแล้ว A+B <> C จะทำให้ Column D เป็นสีแดงครับ Procedure นี้จะตรวจจับการเปลี่ยนแปลงของ 1000 Record ครับสามารถแก้จำนวนได้ที่ส่วนที่ Hilight ไว้ครับ
Mon 26 Jun 2006 08:09:02
ขอโทษนะครับ รบกวน ขอวิธีเพิ่มเติมอีกนิดนึงครับ คือที่ตัวexcelผมต้องใส่สูตร อย่างไรบ้างนะครับ ผมเข้าใจวิธีการทำว่า ที่excel ในเนื้องานให้ใส่สูตร=SUM($A$1:$B$1)<>C1หรือแบบนี้ครับ=IF(SUM(A1:B1)=C1,SUM(A1:B1),"#FF0000")
ส่วนที่Sheet tab
ผมเลือกใส่codeที่sheet 1
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
For i = 1 To 1000
If Cells(i, 1) <> "" And Cells(i, 2) <> "" And Cells(i, 3) <> "" And (Cells(i, 1) + Cells(i, 2)) <> Cells(i, 3) Then
Cells(i, 4).Interior.ColorIndex = 3 'รหัสสีแดงมีค่าเป็น 3
Else
Cells(i, 4).Interior.ColorIndex = 0 'ไม่มีสีรหัสมีค่าเป็น 0
End If
Next i
Application.EnableEvents = True
End Sub
ผมเข้าใจถูกไหมครับ
รบกวนด้วยนะครับ
Tue 27 Jun 2006 17:17:47
ขอบคุณมากครับ
Wed 28 Jun 2006 10:06:17
โทษนะครับ ขออีกทีครับ คือ ผมลองเอาไปประยุกทำกะช่องอื่นแล้วมันมะได้นะครับ แต่ถ้าเป็นA B C D จะไช้กับมันได้ โจทย์คือช่อง E10 มีตัวเลข14611.5 ช่องF10มีตัวเลข1022.81 และ ช่องG10จะเป็นผลบวกของช่องE10คูณ7% (สูตรที่ผมใส่ในช่องG10 =SUM(E10*7%) )แล้วเอาผมรวมจากช่องG10ไปเทียบกับช่องF10ถ้าผลรวมในช่องG10ไม่เท่ากับF10 ให้ช่องG10เป็นสีแดง
ผมลองแก้โค้ดที่ให้มา
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
For i = 5 To 1000
If Cells(i, 5) <> "" And Cells(i, 6) <> "" And Cells(i, 7) <> "" And (Cells(i, 5) + Cells(i, 6)) <> Cells(i, 7) Then
Cells(i, 7).Interior.ColorIndex = 3
Else
Cells(i, 7).Interior.ColorIndex = 0
End If
Next i
Application.EnableEvents = True
End Sub
//ผมเข้าใจว่าเลขที่ให้1เดิมคือเลขคอลัมAผมเลยเปลี่ยนเป็น5=คอลัมE
//ผมเข้าใจว่าเลขที่ให้2เดิมคือเลขคอลัมBผมเลยเปลี่ยนเป็น6=คอลัมF
//ผมเข้าใจว่าเลขที่ให้3เดิมคือเลขคอลัมDผมเลยเปลี่ยนเป็น7=คอลัมG
รบกวนช่วยดูให้ทีครับ
ขอบคุณมากครับ
ส่วนที่ทำไปช่องนั้นเป็นสีแดงเนื่องจากการคำนวณไม่มีการปัดเศษครับ (14611.5 * 0.07 = 1022.805 != 1022.81)
ดังนั้นถ้าต้องการปัดเศษเปลี่ยนสูตรเป็น =ROUND(SUM(E10*7%), 2)
และใน Procedure แก้เป็น
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
For i = 5 To 1000
If Cells(i, 5) <> "" And Cells(i, 6) <> "" And Cells(i, 7) <> "" And Cells(i, 6) <> Cells(i, 7) Then
Cells(i, 7).Interior.ColorIndex = 3
Else
Cells(i, 7).Interior.ColorIndex = 0
End If
Next i
Application.EnableEvents = True
End Sub
ตามนี้ครับ
Wed 28 Jun 2006 18:44:15
โจทย์ excel คือ มีช่องที่ใช้ 3 ช่องคือ E F G ช่องE ใส่ตัวเลข 14611.5 ช่อง Fใส่ตัวเลข 1022.81 ช่อง G สูตรที่ใส่ในช่องGคือ =SUM(E1*7%) แล้วผลรับที่ได้ในช่อง G ถ้าไม่เท่ากับ ช่อง F ให้ช่อง G เป็นสีแดงครับ ปัญหาคือ พอคำตอบ ของช่อง G ไม่เท่ากับ F แล้วช่องG มันก็มีสีแดง แต่พอคำตอบในช่อง G เท่ากับช่อง F แล้ว สีที่ช่อง G มันยังแดงอยู่เลยนะครับ คือต้องการให้เมื่อคำตอบที่ช่อง G กับ F ถ้าเท่ากันให้ช่อง G เป็นสีขาวเหมือนเดิมครับ
รบกวนดูให้ผมทีครับ
ขอบคุณมากครับ
ดังนั้นเปลี่ยนการ handle event จากตรวจจับการเปลี่ยนแปลงใน worksheet เป็น event อื่นๆ เช่น Worksheet_SelectionChange (เมื่อมีการคลิ๊กเปลี่ยน cell ใน worksheet) หรือจะลองจับ Event อื่นๆได้ตามตารางครับ
Worksheet Events
|
Event Name |
Description |
|
Worksheet_Activate |
This event occurs when a worksheet is activated (displayed). |
|
Worksheet_BeforeDoubleClick |
This event occurs when the user double-clicks on a worksheet cell. This event provides a Cancel parameter. |
|
Worksheet_BeforeRightClick |
This event occurs when the user right-clicks on a worksheet cell. This event provides a Cancel parameter. |
|
Worksheet_Calculate |
This event occurs then a cell on the worksheet is calculated. |
|
Worksheet_Change |
This event occurs when the value of a cell is changed. This event does not occur when the value is changed as the result of a calculation. |
|
Worksheet_Deactivate |
This event occurs when a worksheet is deactivated (another worksheet is displayed). |
|
Worksheet_SelectionChange |
This event occurs when the active selection is moved to a new range. |
Workbook Events
|
Event Name |
Description |
|
Workbook_Activate |
This event occurs when the workbook is activated. It does not occur when you switch applications. |
|
Workbook_AddInInstall |
This event occurs when an Add-In module is installed (enabled). |
|
Workbook_AddInUninstall |
This event occurs when an Add-In module is uninstalled (disabled). |
|
Workbook_BeforeClose |
This event occurs when the workbook is closed. This event provides a Cancel parameter. |
|
Workbook_BeforePrint |
This event occurs when the workbook is printed. This event provides a Cancel parameter. |
|
Workbook_BeforeSave |
This event occurs when the workbook is saved. This event provides a Cancel parameter. |
|
Workbook_Deactivate |
This event occurs when the workbook is deactivated. It does not occur when you switch applications. |
|
Workbook_NewSheet |
This event occurs when a new worksheet is added to the workbook. |
|
Workbook_Open |
This event occurs when the workbook is opened. |
|
Workbook_SheetActivate |
This event is the workbook implementation of the Worksheet_Activate event. |
|
Workbook_SheetBeforeDoubleClick |
This event is the workbook implementation of the Worksheet_BeforeDoubleClick event. This event provides a Cancel parameter. |
|
Workbook_SheetBeforeRightClick |
This event is the workbook implementation of the Worksheet_BeforeRightClick event. This event provides a Cancel parameter. |
|
Workbook_SheetCalculate |
This event is the workbook implementation of the Worksheet_Calculate event. |
|
Workbook_SheetChange |
This event is the workbook implementation of the Worksheet_Change event. |
|
Workbook_SheetDeactivate |
This event is the workbook implementation of the Worksheet_Deactivate event. |
|
Workbook_SheetSelectionChange |
This event is the workbook implementation of the Worksheet_SelectioChange event. |
|
Workbook_WindowActivate |
This event occurs when a workbook window is activated. |
|
Workbook_WindowDeactivate |
This event occurs when a workbook window is deactivated. |
|
Workbook_WindowResize |
This event occurs when a workbook window is resized. |
Chart Events
Note: Chart Events apply only to Chart Sheets. They do not apply to ChartObjects embedded in a Worksheet.
|
Event Name |
Description |
|
Chart_Activate |
This event occurs when the chart sheet is activated. |
|
Chart_BeforeDoubleClick |
This event occurs when the user double-clicks on the chart sheet. This event provides a Cancel parameter. |
|
Chart_BeforeRightClick |
This event occurs when the user right-clicks on the chart sheet. This event provides a Cancel parameter. |
|
Chart_Calculate |
This event occurs when the chart is calculated or an element of the chart is changed. |
|
Chart_Deactivate |
This event occurs when the chart sheet is deactivated. |
|
Chart_DragOver |
This event occurs when the user drags data over the chart sheet. |
|
Chart_DragPlot |
This event occurs when the user drags a range of cells over the chart cheet. |
|
Chart_MouseDown |
This event occurs when the user presses a mouse button while over the chart. |
|
Chart_MouseMove |
This event occurs when the user moves the mouse over the chart. |
|
Chart_MouseUp |
This event occurs when the user releases the mouse button. |
|
Chart_Resize |
This event occurs when the chart is resized. |
|
Chart_Select |
This event occurs when the user selects the chart. |
|
Chart_SeriesChange |
This event occurs when the value of the value of a datapoint is changed. |
Application Events
|
Event Name |
Description |
|
App_NewWorkbook |
This event occurs when a new workbook is added. |
|
App_SheetActivate |
This event is the Application implementation of the Worksheet_Activate event. |
|
App_SheetBeforeDoubleClick |
This event is the Application implementation of the Worksheet_BeforeDoubleClick event. This event provides a Cancel parameter. |
|
App_SheetBeforeRightClick |
This event is the Application implementation of the Worksheet_BeforeRightClick event. This event provides a Cancel parameter. |
|
App_SheetCalculate |
This event is the Application implementation of the Worksheet_Calculate event. |
|
App_SheetChange |
This event is the Application implementation of the Worksheet_Change event. |
|
App_SheetDeactivate |
This event is the Application implementation of the Worksheet_Deactivate event. |
|
App_SheetSelectionChange |
This event is the Application implementation of the Worksheet_SelectionChange event. |
|
App_WindowActivate |
This event is the Application implementation of the Workbook_WindowActivate event. |
|
App_WindowDeactivate |
This event is the Application implementation of the Workbook_WindowDeactivate event. |
|
App_WindowResize |
This event is the Application implementation of the Workbook_WindowResize event. |
|
App_WorkbookActivate |
This event is the Application implementation of the Workbook_Activate event. |
|
App_WorkbookAddInInstall |
This event is the Application implementation of the Workbook_AddInInstall event. |
|
App_WorkbookAddInUninstall |
This event is the Application implementation of the Workbook_AddInUnInstall event. |
|
App_WorkbookBeforeClose |
This event is the Application implementation of the Workbook_BeforeClose event. This event provides a Cancel parameter. |
|
App_WorkbookBeforePrint |
This event is the Application implementation of the Workbook_BeforePrint event. This event provides a Cancel parameter. |
|
App_WorkbookBeforeSave |
This event is the Application implementation of the Workbook_BeforeSave event. This event provides a Cancel parameter. |
|
App_WorkbookDeactivate |
This event is the Application implementation of the Workbook_Deactivate event. |
|
App_WorkbookNewSheet |
This event is the Application implementation of the Workbook_NewSheet event. |
|
App_WorkbookOpen |
This event is the Application implementation of the Workbook_Open event. |
Thu 29 Jun 2006 10:14:00
รบกวนดูให้ผมด้วยนะครับ ปัญหาคือ คำตอบที่ได้จากช่องGถ้าไม่เท่ากับช่องFให้ขึ้นสีแดง แต่ถ้าคำตอบช่องGเท่ากับช่องFให้สี เป็นปกติ
http://www.root999.th.gs/web-r/oot999/Book1.rar
รบกวนด้วยนะครับ
Thu 29 Jun 2006 10:18:45
รบกวนดูให้ผมด้วยนะครับ ปัญหาคือ คำตอบที่ได้จากช่องGถ้าไม่เท่ากับช่องFให้ขึ้นสีแดงที่ช่องG แต่ถ้าคำตอบช่องGเท่ากับช่องFให้สี เป็นปกติที่ช่องG
http://www.root999.th.gs/web-r/oot999/Book1.rar
รบกวนด้วยนะครับ
Thu 29 Jun 2006 17:30:57
รบกวนนิดนึงครับ ตัวอย่างที่ให้มา พอคลิ๊กเปิดปุป มันขึ้น ข้อความ ตามภาพ ในlink ที่ผมแนบมานี้นะครับ http://www.root999.th.gs/
พอเปิดfileตัวอย่างที่ให้มามันก็ขึ้นมาทันที รู้สึกว่ามันทำให้โค้ดVBAไม่ทำงานนะครับ มีทางแก้ไหมครับ รบกวนด้วยนะครับ
ขอบคุณมากครับ
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.EnableEvents = False
For i = 1 To 1000
If Cells(i, 5) <> "" And Cells(i, 6) <> "" And Cells(i, 7) <> "" And Cells(i, 7) <> Cells(i, 6) Then
Cells(i, 7).Interior.ColorIndex = 3
Else
Cells(i, 7).Interior.ColorIndex = 0
End If
Next i
Application.EnableEvents = True
End Sub
Fri 30 Jun 2006 08:17:34
โทษนะครับ โค้ดโปรแกรม ใช้ได้ดีไม่มีปัญหา มันติดปัญหาตรงที่ พอเปิดexcel ปุ๊บ มันขึ้นข้อ ความตาม link http://www.root999.th.gs/ นี้เลยนะครับ รบกวนขอวิธีแกปัญหาทีครับ
ผมต้องลงโปรแกรมอะไรเพิ่มอีกอะเปล่าครับ เป็นทุกเครื่องที่เอาไปเปิดเลยครับ มันจะใช้ได้ตอนที่เอาfile ไปทำใหม่ แต่พอsave แล้วเปิดขึ้นมาใหม่ ก็จะมีข้อความแบบนี้(ตามlinkที่แนบมานะครับ)ขึ้นมานะครับ
รบกวนด้วยนะครับ
Fri 30 Jun 2006 10:50:52
ขอบคุณมากๆ นะครับ ถ้า แก้ตรงที่บอกมันจะมีผลอะไรไหมครับ
Fri 30 Jun 2006 10:52:18
ขอบคุณมากๆ นะครับ ถ้า แก้ตรงที่บอกมันจะมีผลอะไรไหมครับ
Fri 30 Jun 2006 13:24:26
ขอบคุณมากๆครับ
Thu 20 Sep 2007 16:02:50
ขอสูตร excel 2003 ตัวเลขเป็นข้อความภาษาอังกฤษ
ถ้า excel 2000 จะใช้ =spellnumber
Wed 2 Jan 2008 17:18:07
ขอบคุณ ค่ะ
Fri 18 Jan 2008 16:02:58
Fri 18 Jan 2008 17:54:06
การเปลี่ยนสี Cell ตามเงื่อนไขที่ต้องการ
การให้แสดงค่าตามเงื่อนไขที่ต้องการ
Sat 9 Feb 2008 15:34:22
Sun 10 Feb 2008 17:57:18
Mon 17 Mar 2008 11:17:20
ถ้าเก็บข้อมูลลงในExcel แล้วต้องการให้มีข้อความแจ้งเตือน หรือทำเป็นสีกระพริบที่ข้อความนั้นว่าใกล้ถึงเวลาหมดอายุแล้ว ทำยังไงใครก็ได้ช่วยตอบที
Mon 17 Mar 2008 21:38:02
Sun 4 May 2008 15:08:51
อยากเปรียบเทียบข้อความที่คล้ายกันแต่ไม่เหมือนซะทีเดียว
ไม่อยากใช้ EXACT เพราะมันแค่บอกว่า TRUE FALSE แต่อยากให้มันบอกว่าไม่เหมือนหน่ะตรงใหนมีสูตรมัยค่ะ
Sun 4 May 2008 15:17:13
Sun 4 May 2008 15:20:01
ขอโทษนะคะ รู้จักแต่ vlookup มันไม่เหมือนกันใช่มั๊ยค่ะ
ไม่ทราบใช้อย่างไรมีตัวอย่างมั๊ยคะ
Sun 4 May 2008 16:01:58
Mon 5 May 2008 14:12:19
Mon 5 May 2008 20:57:04
Sat 21 Jun 2008 14:44:38
Sun 22 Jun 2008 09:59:22
Tue 4 Nov 2008 16:15:29
Wed 5 Nov 2008 09:33:41

















