Page 1 of 1
protect sheet แล้วต้องการ auto refresh data
Posted: Tue Aug 02, 2016 11:40 am
by browny.m
ใช้ macro เพื่อเปิด protect sheet ด้วย password แล้ว refresh all แต่ excel ยังฟ้องว่าจะ auto refresh ไม่ได้ หาก protect sheet
Application.ScreenUpdating = False
Sheets("W1").Unprotect Password:="0857"
ActiveWorkbook.RefreshAll
Sheets("W1").Protect Password:="0857"
'UserInterfaceOnly:=True
รบกวน macro code กับ ทาง อ. ด้วยคะ ขอบคุณคะ
Re: protect sheet แล้วต้องการ auto refresh data
Posted: Tue Aug 02, 2016 1:16 pm
by menem
Application.ScreenUpdating = False
Sheets("W1").Unprotect Password:="0857"
ActiveWorkbook.RefreshAll
DoEvents
Sheets("W1").Protect Password:="0857"
'UserInterfaceOnly:=True
ลองดูนะครับว่าใช้ได้หรือไม่
แต่โดยปกติ ผมจะสั่งให้ QueryInBackground = false นะครับ
เพราะหากเป็น True คำสั่ง ProtectSheet จะเริ่มทำก่อนที่การ Refresh จะเสร็จ
Re: protect sheet แล้วต้องการ auto refresh data
Posted: Tue Aug 02, 2016 1:35 pm
by browny.m
หมายถึง ใส่ QueryInBackground = false ไว้ตรงตำแหน่งไหนคะ
เขียน code ไม่เป็นเลยคะ หาเจอจากในเน็ต แต่ลองมารันแล้วมันทำไม่ได้คะ
Re: protect sheet แล้วต้องการ auto refresh data
Posted: Tue Aug 02, 2016 1:53 pm
by browny.m
มันก็ยังฟ้องตามภาพคะ
protect Sheet.jpg
Re: protect sheet แล้วต้องการ auto refresh data
Posted: Tue Aug 02, 2016 3:14 pm
by browny.m
ทำได้เองแล้วคะ