Skip i'r prif gynnwys

Sut i glirio cynnwys celloedd penodedig ar agor ac allanfa yn llyfr gwaith Excel?

Mae'r erthygl hon yn sôn am glirio cynnwys celloedd penodedig wrth agor neu gau llyfr gwaith Excel.

Clirio cynnwys celloedd penodedig ar y llyfr gwaith ar agor ac allanfa


Clirio cynnwys celloedd penodedig ar y llyfr gwaith ar agor ac allanfa

Gwnewch fel a ganlyn i glirio cynnwys celloedd penodedig ar y llyfr gwaith yn agored ac yn gadael.

Yn gyntaf, mae angen i chi gadw'r llyfr gwaith sydd ei angen arnoch i glirio cynnwys celloedd penodedig wrth agor neu allanfa fel Llyfr Gwaith Macro-alluogi Excel.

1. Cliciwch Ffeil > Save As > Pori. Gweler y screenshot:

2. Yn y Save As blwch deialog, dewiswch ffolder i achub y llyfr gwaith, rhowch enw newydd yn y enw ffeil blwch yn ôl yr angen, dewiswch Llyfr Gwaith Macro-alluogedig Excel oddi wrth y Sava fel math rhestr ostwng, ac yna cliciwch ar y Save botwm.

3. Yn y popping up Microsoft Excel blwch deialog, cliciwch y OK botwm fel y dangosir isod screenshot.

4. Agorwch y Llyfr Gwaith Macro-alluog rydych chi wedi'i arbed nawr, pwyswch y Alt + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

5. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch ddwywaith Llyfr Gwaith hwn yn y cwarel chwith, ac yna copïwch isod god VBA i mewn i ffenestr y Cod.

Cod VBA 1: Clirio cynnwys celloedd penodedig ar y llyfr gwaith ar agor

Private Sub Workbook_Open()
'Updated by Extendoffice 20190712
    Application.EnableEvents = False
        Worksheets("test").Range("A1:A11").Value = ""
    Application.EnableEvents = True
End Sub

Cod VBA 2: Clirio cynnwys celloedd penodedig ar allanfa'r llyfr gwaith

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Updated by Extendoffice 20190712
    Worksheets("test").Range("A1:A11").Value = ""
End Sub

Nodyn: Yn y codau uchod, prawf, ac A1: A11 yw enw'r daflen waith a'r ystod gell y byddwch chi'n clirio cynnwys ohoni. Newidiwch nhw yn ôl yr angen.

6. Gwasgwch y Alt + Q allweddi i adael y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

O hyn ymlaen, wrth agor neu gau'r llyfr gwaith, bydd cynnwys celloedd penodol mewn taflen waith benodol yn cael ei glirio'n awtomatig.


Erthyglau cysylltiedig:

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thank You Crystal! It works.

G
This comment was minimized by the moderator on the site
Dear Friends I tried the suggested code with no effect on open>

Private Sub Workbook_Open()


Application.EnableEvents = False

Worksheets("Clienti").Range("A9:K900").Value = ""

Application.EnableEvents = True

End Sub


The macro does work from within the workbook but not when the workbook opens.

Any help would be greatly appreciated!
This comment was minimized by the moderator on the site
Hi TUDOSE GELU,
The code works well in my case.
Don't forget to put the code in the ThisWorkbook (Code) window, and save the workbook as an Excel Macro-Enabled Workbook.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/2022-oct/oct-2.png
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/2022-oct/oct-1.png
This comment was minimized by the moderator on the site
Can someone help me how to blankout cells of sheet (only in a row and not entire Sheet). Below code removes contents in all rows of the sheet. But I want contents to be cleared only in row9



Private Sub Workbook_Open()

'Updated by Extendoffice 20190712

Application.EnableEvents = False

Worksheets("test").Range("A1:A11").Value = ""

Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Hi,
The above VBA only clear the cell value of range A1:A11. If you want to clear only the values in row 9, you can replace A1:A11 with 9:9. See the below code.

Private Sub Workbook_Open()

'Updated by Extendoffice 20200522

Application.EnableEvents = False

Worksheets("test").Range("9:9").Value = ""

Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Can someone help me how to blankout cells of sheet (only in a row and not entire Sheet). Below code removes contents in all rows of the sheet. But I want contents to be cleared only in row9

Private Sub Workbook_Open()

'Updated by Extendoffice 20190712

Application.EnableEvents = False

Worksheets("test").Range("A1:A11").Value = ""

Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Hello, for the range how would I enter the code if I want to select multiple range or cells?
This comment was minimized by the moderator on the site
Dear sir/madam, my sheet is protected and only specified cell (for data clearing) is not protected but when i enter the value in the specified & then re-open the excel file then value is cleared by VBA code but the specified cell is protected, i have to un-protect cell by un-protecting the sheet edit the editable range again & again so please fix.
Thanks in advance
This comment was minimized by the moderator on the site
Hi Sanjay Sharma,
Sorry for the inconvinience. Please apply the below VBA codes and remember to replace the sheet name and the range to your needs. Thank you for your comment.

VBA code 1:
Private Sub Workbook_Open()
Application.EnableEvents = False
Worksheets("Sheet1").Range("A1:A11").Value = ""
Application.EnableEvents = True
End Sub

VBA code 2:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("Sheet1").Range("A1:A11").Value = ""
End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations