EXCEL TOOLS
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
[code]
และปิดด้วย [/code]
ตัวอย่างเช่น [code]dim r as range[/code]
เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)Code: Select all
Sub Clear_Tab_color()
'
' Clear_Tab_color Macro
'
'
Sheets("Sheet1").Activate
With ActiveWorkbook.Sheets("Sheet1").Tab
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
With ActiveWorkbook.Sheets("Sheet3").Tab
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
With ActiveWorkbook.Sheets("Sheet2").Tab
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
Sheets("Sheet1").Select
Range("B2").Select
End Sub
ลองปรับเป็นMarch201711 wrote: ↑Thu Apr 19, 2018 11:50 am สอบถามค่ะ ในทุก sheet จะมี Tab สีเขียวอยู่ อยากจะ Clear tab color ที่เป็นสีเขียวให้เป็นไม่เติมสี แต่พอ record marco แล้ว มันขึ้น debug ต้องปรับ code อย่างไรค่ะ ตามรูปค่ะCode: Select all
Sub Clear_Tab_color() ' ' Clear_Tab_color Macro ' ' Sheets("Sheet1").Activate With ActiveWorkbook.Sheets("Sheet1").Tab .ColorIndex = xlAutomatic .TintAndShade = 0 End With With ActiveWorkbook.Sheets("Sheet3").Tab .ColorIndex = xlAutomatic .TintAndShade = 0 End With With ActiveWorkbook.Sheets("Sheet2").Tab .ColorIndex = xlAutomatic .TintAndShade = 0 End With Sheets("Sheet1").Select Range("B2").Select End Sub
Code: Select all
Sub Clear_Tab_color()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.Tab.ColorIndex = xlColorIndexNone
Next sht
End Sub
Code: Select all
Sub Clear_Tab_color()
Sheets("Sheet1").Tab.ColorIndex = xlColorIndexNone
Sheets("Sheet2").Tab.ColorIndex = xlColorIndexNone
Sheets("Sheet3").Tab.ColorIndex = xlColorIndexNone
End Sub
ปรับตามนี้ครับทั้ง2โค้ดMarch201711 wrote: ↑Thu Apr 19, 2018 10:07 pm ขอถามเพิ่มอีกนิดค่ะ อยากให้ทุก sheet อยู่ที่ cell a1 ต้องปรับ code อย่างไรคะ
Code: Select all
Sub Clear_Tab_color()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.Select
Range("A1").Select
sht.Tab.ColorIndex = xlColorIndexNone
Next sht
End Sub
Code: Select all
Sub Clear_Tab_color()
Sheets("Sheet1").Tab.ColorIndex = xlColorIndexNone
Sheets("Sheet1").Select
Range("a1").Select
Sheets("Sheet2").Tab.ColorIndex = xlColorIndexNone
Sheets("Sheet2").Select
Range("a1").Select
Sheets("Sheet3").Tab.ColorIndex = xlColorIndexNone
Sheets("Sheet3").Select
Range("a1").Select
End Sub