Skip to main content

Conas cluaisín bileoga oibre a ghlasáil nó a reoiteáil isteach Excel?

Má tá leabhar oibre agat ina bhfuil iliomad bileoga oibre, tá bileog oibre darb ainm Príomhbhileog mar an chéad chluaisín sa leabhar oibre. Agus anois, ba mhaith leat iarracht a dhéanamh an cluaisín bileog seo a ghlasáil nó a reo chun é a dhéanamh infheicthe i gcónaí fiú agus tú ag scrollaigh thar roinnt bileoga oibre. Déanta na fírinne, níl aon bhealach díreach ann chun an cluaisín a reo, ach, is féidir leat beart oibre a úsáid chun déileáil leis an bhfadhb seo.

Cluaisín bileog oibre ar leith a ghlasáil nó a reo le cód VBA


mboilgeog cheart gorm saighead Cluaisín bileog oibre ar leith a ghlasáil nó a reo le cód VBA

In Excel, is féidir linn an cód VBA seo a leanas a chur i bhfeidhm chun an bhileog oibre ar leith a dhéanamh i gcónaí roimh do chluaisín bileog oibre a chliceáiltear faoi láthair, ionas gur féidir leat an bhileog oibre seo a fheiceáil i gcónaí nuair a scrollaíonn tú thar aon cluaisíní bileog eile. Déan mar seo a leanas le do thoil:

1. Coinnigh síos an ALT + F11 eochracha, agus osclaíonn sé an Fuinneog Microsoft Visual Basic for Applications.

2. Ansin roghnaigh An Leabhar Oibre seo ón taobh clé Explorer Tionscadail pána, cliceáil faoi dhó é chun an Modúil, agus ansin cóipeáil agus greamaigh an cód VBA seo a leanas sa Mhodúl bán:

Cód VBA: Déan cluaisín bileog oibre ar leith a reo nó a ghlasáil

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Update by Extendoffice
Application.EnableEvents = False
Application.ScreenUpdating = False
If Application.ActiveSheet.Index <> Application.Sheets("Main-sheet").Index Then
    Application.Sheets("Main-sheet").Move Before:=Application.Sheets(Application.ActiveSheet.Index)
    Application.Sheets("Main-sheet").Activate
    Sh.Activate
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

doc-reo-bhileog-cluaisín-1

3. Agus ansin an cód seo a shábháil agus a dhúnadh, anois, nuair a chliceálann tú aon cheann de do chluaisín bileog oibre, beidh an bhileog oibre shonrach seo i gcónaí ag tosach do chluaisín leatháin chliceáilte, féach scáileáin scáileáin:

doc-reo-bhileog-cluaisín-2
-1
doc-reo-bhileog-cluaisín-3

nótaí: Sa chód thuas, is é an Príomhbhileog ainm na bileoige a theastaíonn uait a reo, is féidir leat é a athrú go do riachtanas.


Earraí gaolmhara:

Conas Pannaí a Reo i Excel 2010?

Conas painéil reo / neamh-reo a chur i bhfeidhm ar iliomad bileoga oibre ag an am céanna?

Uirlisí Táirgiúlachta Oifige is Fearr

Oifig Tacaíochta/Excel 2007-2021 agus 365 | Ar fáil i 44 Teanga | Éasca le Díshuiteáil go hiomlán

Gnéithe Coitianta: Aimsigh/Aibhsigh/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 go Words, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Kutools for Excel Tá breis is 300 gné ann, A chinntiú nach bhfuil uait ach cliceáil ar shiúl...

Supercharge Do Excel scileanna: Éifeachtúlacht Taithí Mar Riamh Roimhe Le Kutools for Excel  (Triail Iomlán 30-Lá Saor in Aisce)

cluaisín kte 201905

Ráthaíocht Neamhchoinníollach Airgid Ar Ais 60-LáLeigh Nios mo... Íoslódáil saor in aisce ... Ceannach ... 

Office Tab Tugann sé comhéadan Tabbed chuig Oifig, agus Déan do chuid Oibre i bhfad níos éasca

  • Cumasaigh eagarthóireacht agus léamh tabáilte isteach Word, Excel, Pointe cumhachta, 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éaduithe ar do tháirgiúlacht faoi 50%, agus laghdaítear na céadta cad a tharlaíonn nuair luiche duit gach lá! (Triail Iomlán 30-Lá Saor in Aisce)
Ráthaíocht Neamhchoinníollach Airgid Ar Ais 60-LáLeigh Nios mo... Íoslódáil saor in aisce ... Ceannach ... 
 
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
chăng đc gi cả
This comment was minimized by the moderator on the site
As Thuyen pointed out 2 years ago, you can't copy data between sheets while this code is active. Furthermore, the code is needlessly complicated. The sheet that you activate is passed to the procedure as the parameter "Sh". This makes the frequent calls to "ActiveSheet" unnecessary, and could cause problems for someone who's trying to modify the code but isn't very experienced.

Here's my versions that corrects those issues, and even shows how to add a 2nd "Main" sheet (similar to what Dzingai posted):
-----------------------------------------------------------------

'These 2 lines aren't necessary if you use the sheets' codenames, which I recommend.
Set shtMain1 = Worksheets("Main-Sheet-1")
Set shtMain2 = Worksheets("Main-Sheet-2")

If Application.CutCopyMode = False Then
If Sh.Index <> shtMain1.Index And Sh.Index <> shtMain2.Index Then
shtMain1.Move before:=Sh
shtMain2.Move before:=Sh
Sh.Activate
End If
End If
This comment was minimized by the moderator on the site
This code worked well. Only problem is...if we close the file & open it again it goes off.
This comment was minimized by the moderator on the site
[quote]This code worked well. Only problem is...if we close the file & open it again it goes off.By Sangs[/quote] Try saving document as Macro-Enabled Workbook. I think it should work well that way.
This comment was minimized by the moderator on the site
Is it possible to create one with multiple arguments? Like instead of just moving the one main sheet to the front of where you are working, is it possible to move three tabs in front of what you are working on?
This comment was minimized by the moderator on the site
Yes, it is possible, you just have to add more arguments to the if clause using the "AND" like this IF Application.ActiveSheet.Index Application.Sheets("Main-sheet").Index AND Application.ActiveSheet.Index Application.Sheets("Other-Main-sheet").Index and so on... Then Application.Sheets("Main-sheet").Move Before:=Application.Sheets(Application.Sheets("Other-Main-sheet").Index) Application.Sheets("Main-sheet").Activate Application.Sheets("Other-Main-sheet").Move Before:=Application.Sheets(Application.ActiveSheet.Index) Application.Sheets("Other-Main-sheet").Activate Sh.Activate This will place the Main-Sheet, then the Other-Main-Sheet in front of your active sheet.
This comment was minimized by the moderator on the site
is this vba my excel sheet not freezeplease give me solution
This comment was minimized by the moderator on the site
Could not get your code to work, but this one did :) Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim sc As Long ' count of sheets Dim NewPos As Long ' index of serlected sheet Application.EnableEvents = False Application.ScreenUpdating = False If ActiveSheet.Index 1 Then sc = Sheets.Count NewPos = ActiveSheet.Index For i = 2 To NewPos - 1 Sheets(2).Move After:=Sheets(sc) Next i Sheets(1).Activate Sheets(2).Activate End If Application.ScreenUpdating = True Application.EnableEvents = True End Sub
This comment was minimized by the moderator on the site
When I use VBA, I cannot copy data from Main-Sheet to another sheet Please help me fix this bug
This comment was minimized by the moderator on the site
hahaha. so true! did you find a fix for this?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations