Skip to main content

Conas bosca seiceála uathoibríoch a dhéanamh i gcill in Excel?

Agus boscaí seiceála á gcur isteach i gcealla in Excel, b’fhéidir go dtabharfá faoi deara go bhfuil sé deacair gach bosca seiceála a shocrú go hordúil mar a thaispeántar an pictiúr ar chlé. I ndáiríre, is féidir leat gach bosca seiceála a bhogadh go lár na gceall chun iad a choinneáil in ord néata. Is féidir le modh san alt seo cabhrú leat.

Bosca seiceála uathoibríoch-ionaid i gcill le cód VBA


Bosca seiceála uathoibríoch-ionaid i gcill le cód VBA

Chun gach bosca seiceála i gcealla a bhileog go huathoibríoch i mbileog oibre reatha, déan mar a leanas le do thoil.

1. Sa bhileog oibre, ní mór duit gach bosca seiceála a lárnú go huathoibríoch, brúigh an Eile + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil le do thoil Ionsáigh > Modúil. Ansin cóipeáil agus greamaigh cód VBA isteach i bhfuinneog an chóid.

Cód VBA: Lárnaigh gach bosca seiceála i gcealla go huathoibríoch

Sub CenterCheckbox ()
    Dim xRg As Range
    Dim chkBox As OLEObject
    Dim chkFBox As CheckBox
    On Error Resume Next
    Application.ScreenUpdating = False
    For Each chkBox In ActiveSheet.OLEObjects
        If TypeName(chkBox.Object) = "CheckBox" Then
            Set xRg = chkBox.TopLeftCell
            chkBox.Width = xRg.Width * 2 / 3
            chkBox.Height = xRg.Height
            chkBox.Left = xRg.Left + (xRg.Width - chkBox.Width) / 2
            chkBox.Top = xRg.Top + (xRg.Height - chkBox.Height) / 2
        End If
    Next
    For Each chkFBox In ActiveSheet.CheckBoxes
        Set xRg = chkFBox.TopLeftCell
        chkFBox.Width = xRg.Width * 2 / 3
        chkFBox.Height = xRg.Height
        chkFBox.Left = xRg.Left + (xRg.Width - chkFBox.Width) / 2
        chkFBox.Top = xRg.Top + (xRg.Height - chkFBox.Height) / 2
    Next
    Application.ScreenUpdating = True
End Sub

3. Brúigh an F5 eochair. Ansin bogtar gach bosca seiceála isteach i lár na gcealla láithreach mar a thaispeántar thíos.

nótaí: Is féidir an cód VBA seo a chur i bhfeidhm ar CheckBox (Rialú ActiveX) agus CheckBox (Rialú Foirme).

Leid: Más mian leat ilbhoscaí seiceála a chur isteach i raon roghnaithe ar an mórchóir, is féidir leat triail a bhaint as an Boscaí Seiceála Iontrála Baisc fóntais pf Kutools le haghaidh Excel. Nó cuir isteach Cnaipí Rogha iolracha leis an Cnaipí Rogha Iontrála Baisc fóntais. Thairis sin, is féidir leat gach bosca seiceála a scriosadh ag an am céanna leis an Boscaí Seiceála Baisc Scrios fóntais mar atá thíos scáileáin scáileáin a thaispeántar. Is féidir leat dul go íoslódáil saor in aisce na bogearraí gan aon teorannú i 30 lá.


Earraí gaolmhara:

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The VBA does not work at all for me. When I press F5, it appears that the module runs, but the checkboxes did not move.
This comment was minimized by the moderator on the site
After some more experimenting, I figured out that the VBA does work for manually inserted checkboxes, but if I use Kutools batch insert, it does not. How do I center all the checkboxes inserted with Kutools?
This comment was minimized by the moderator on the site
Hi quadma,
The code also works for the checkboxes inserted by Kutools. Which Excel version are you using?
This comment was minimized by the moderator on the site
I'm using office 360. I think the issue that I'm having is that when I use the Kutools batch insert, the size of the the checkbox object is as wide as the column that it's inserted into (i.e. the checkbox object width is greater than it's height), with the visible checkbox itself on being left justified within the object. If I select all the checkbox objects and then resize them so that the height and length are equal, and then run the VBA, it does then center the checkboxes within the column.





This seems like an unnecessary step, given that checkboxes are square, why is Kultools not making the checkbox objects square?
This comment was minimized by the moderator on the site
Hi quadma,
The check boxes inserted by Kutools are the same as the Check Box (Form Control) which inserted by Excel.
I don't really understand you said "making the checkbox object square". Normally a check box include the box field and the value field. Kutools keeps the check boxes' value empty if the selected cells are blank. And if there are values in selected cells, the cell value will be taken as the check box value.
This comment was minimized by the moderator on the site
I've uploaded a picture to show what I mean. Hopefully that helps.
This comment was minimized by the moderator on the site
Hi quadma, I got your point. We will think about it and thank you for your patience.
This comment was minimized by the moderator on the site
This worked great for me except it doesn't align it with the text in the next cell which is bottom aligned. Is there a way to align the checkboxes for bottom aligned in order to get them to align with the text in the next cell? Thanks!
This comment was minimized by the moderator on the site
You VDA script is partly working. Because when i applied it, linked cell next to Checkbox get changed and got linked with a cell under it.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations