Page 1 of 1
อยากเปลี่ยน Tab sheet ทุก sheet ไม่ให้มีสี แต่ run marco แล้วติด Debug ค่ะ
Posted: Thu Apr 19, 2018 11:50 am
by March201711

สอบถามค่ะ ในทุก 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
Re: อยากเปลี่ยน Tab sheet ทุก sheet ไม่ให้มีสี แต่ run marco แล้วติด Debug ค่ะ
Posted: Thu Apr 19, 2018 11:58 am
by puriwutpokin
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
Re: อยากเปลี่ยน Tab sheet ทุก sheet ไม่ให้มีสี แต่ run marco แล้วติด Debug ค่ะ
Posted: Thu Apr 19, 2018 1:37 pm
by March201711
ได้แล้วค่ะ ขอบคุณ คุณ puriwutpokin มากค่ะ
Re: อยากเปลี่ยน Tab sheet ทุก sheet ไม่ให้มีสี แต่ run marco แล้วติด Debug ค่ะ
Posted: Thu Apr 19, 2018 10:07 pm
by March201711
ขอถามเพิ่มอีกนิดค่ะ อยากให้ทุก sheet อยู่ที่ cell a1 ต้องปรับ code อย่างไรคะ
Re: อยากเปลี่ยน Tab sheet ทุก sheet ไม่ให้มีสี แต่ run marco แล้วติด Debug ค่ะ
Posted: Thu Apr 19, 2018 10:45 pm
by puriwutpokin
March201711 wrote: Thu Apr 19, 2018 10:07 pm
ขอถามเพิ่มอีกนิดค่ะ อยากให้ทุก sheet อยู่ที่ cell a1 ต้องปรับ code อย่างไรคะ
ปรับตามนี้ครับทั้ง2โค้ด
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
Re: อยากเปลี่ยน Tab sheet ทุก sheet ไม่ให้มีสี แต่ run marco แล้วติด Debug ค่ะ
Posted: Fri Apr 20, 2018 11:36 am
by March201711
ได้แล้วค่ะ ขอบคุณ คุณ Puriwutpokin มากค่ะ
