Sida loo doorto unug leh VBA gudaha Excel (6 siyaabood oo faa'iido leh)

  • La Wadaag Tan
Hugh West

Maqaalkan, waxaan ku tusi doonaa sida aad u dooran karto unug ama unugyo kala duwan oo leh VBA gudaha Excel. Waxaad baran doontaa inaad doorato hal, unugyo kala duwan, unug leh magacyo kala duwan, iyo unug la xidhiidha unug kale oo leh VBA .

Download Practice Workbook. 2>

Dooro Unug leh VBA.xlsm

6 Siyaabaha Faa'iido Leh ee Lagu Doorto Unug leh VBA gudaha Excel

<0 Aan sahamino 6 da hab ee ugu faa'iidada badan si loo doorto unug ama unugyo kala duwan oo leh VBA .

1. Dooro Unugga Warqadda Shaqada ee Firfircoon ee VBA ee Excel

Ugu horreyntii, aynu dooranno unugga xaashida shaqada ee firfircoon VBA gudaha Excel.

Waa kan Waxaan helay buug shaqo oo la yiraahdo bookbook1 . Waxa jira saddex waraaqood oo la yidhaahdo Sheet1 , Sheet2 , iyo Sheet3 oo ku jira buugga shaqada. Xaashida shaqada ee firfircooni waa Sheet1 .

Waxaad isticmaali kartaa laynka soo socda ee koodka si aad u doorato unug kasta ( C5 ee tusaalahan) xaashida shaqada ee firfircoon:

7> ActiveSheet.Cells(5,3).Select

>

Wax soo saarka: > 3>

Orod. Waxayna dooran doontaa unugga C5 ee xaashida shaqada ee firfircoon Sheet1 ee Buug-shaqeedka1 .

>

2. Dooro Unugga Buug-hawleed Firfircoon laakiin maaha Xaashiyaha Shaqada ee Firfircoon ee leh VBA ee Excel

Hadda, aynu doorano unugga buugga shaqada ee firfircoon, laakiin maaha xaashida shaqada ee firfircoon. Xaashida shaqadayada firfircoon waa Sheet1 , laakiin markan waannu dooran doonnaaunugga C5 ee Sheet2 .

Waxaad isticmaali kartaa xariiqda koodka:

>

> ⧭

> VBA Code : > Application.Goto Sheets("Sheet2").Range("C5")

Ama,

>> Application.Goto Sheets("Sheet2").Cells(5,3)

Ama,

6>

Sheets("Sheet2").Activate

Range("C5").Select

Wax soo saar: >

Daar. Waxayna dooran doontaa unugga C5 ee xaashida shaqada Sheet2 ee buugga shaqada ee firfircoon Buugga shaqada1 .

1>3. Ka dooro Unug ka baxsan Buug-hawleed Firfircoon oo leh VBA gudaha Excel >

Markan waxaan dooran doonnaa unug, kama dooranno buugga shaqada.

> 2>. Laakin waxaan ku haynaa buug kale oo la yiraahdo Workbook2isla galkiina.

Aan doorano unugga C5 ee Sheet1 of Workbook2 .

Sadka VBA koodku wuxuu noqonayaa:

> ⧭ Xeerka VBA:

> 7> Application.Goto Workbooks("Workbook2.xlsx").Sheets("Sheet1").Range("C5")

Ama,

>>> Application.Goto Workbooks("Workbook2.xlsx").Sheets("Sheet1").Cells(5,3)

Ama,

>>

Workbooks("Workbook2.xlsx").Activate

> Sheets("Sheet1").Select >

Koodhka socodsii oo waxa uu dooran doonaa unugga C5 ee Sheet1 ee Buugga shaqada2 .

<8 4. Dooro Range of Cells with VBA in Excel

Illaa hadda, waxaanu dooranay hal unug oo kaliya.

Markan waxaanu dooran doonaa unugyo kala duwan (Aynu nidhaahno B4:C13 Tusaalahan)

Haddii ay tahay xaashida shaqada ee firfircoon, waxaad isticmaali kartaa:

> > VBA Code: >> Range("B4:C13").Select

>

Wax-soo-saarka>Waxay dooran doontaa unugyada B4:C13 ee xaashida shaqada ee firfircoon Sheet1 ee Buug-shaqaale1 .

>

Haddii ay tahay buugga shaqada ee firfircoon, laakiin aan ahayn xaashida shaqada ee firfircoon ( Sheet2 ee tusaalahan), isticmaal :

> > Wax soo saar:>>>Waxay dooran doontaa unugyada B4:C13ee Sheet2buugga shaqada ee firfircoon > Buug-shaqeedka1.

Oo haddii aad rabto inaad ka doorato unugyo kala duwan oo ka mid ah buug-shaqeedka aan firfircoonayn ( Buugga shaqada2 tusaalahan), Isticmaal khadkan koodka:

>

VBA Code:

>>> Application.Goto Workbooks("Workbook2.xlsx").Sheets("Sheet2").Range("B4:C13") >

> ee Buug-shaqeedka2 .

5. Dooro Unug ka mid ah Range Magacaaban oo leh VBA gudaha Excel >

>Waxa kale oo aad dooran kartaa hal ama in ka badan oo unug La magacaabay Range oo wata VBA gudaha Excel.

Halkan xaashida firfircoon ee Sheet1 ee Buug-shaqeedka1 , waxaanu ku helnay Lagu magacaabay Range oo loo yaqaan ABC kaas oo ka kooban kala duwan B4:C13 .

Si aad u dooratid Rangeka la magacaabay ABC , isticmaal laynka koodka:

>

>> ⧭

1> Xeerka VBA:>> Range("ABC").Select

1> Wax soo saarka: >

>

Waxay dooran doontaa Range La magacaabay .

6. Dooro unug qaraabo ah unug kale oo leh VBA gudaha Excel >

>Ugu dambayntii, waxaad dooran kartaa unug qaraabo ah unug kale VBA.> Waxaad isticmaali kartaa Hanti kabaxsanof VBAtanUjeedada.

Tusaale ahaan, aynu doorano unugga 2 safafka hoose iyo 3 oo ka soo baxa unugga C5 ee xaashida shaqada ee firfircoon > Sheet1 of Buug-shaqeedka1 .

Isticmaal khadka soo socda ee koodka:

VBA Code: 3> > > Range("C5").Offset(2, 3).Select

ama,

> Cells(5,3).Offset(2, 3).Select

Wax-soo-saarka : >> C5 .

Gabagabada

Adiga oo isticmaalaya hababkan, waxaad dooran kartaa unug ama unugyo kala duwan oo leh VBA ee Excel. Wax su'aalo ah ma qabtaa? Xor baad u tahay inaad na waydiiso.

Hugh West waa tababare iyo falanqeeye heer sare ah oo tayo sare leh oo khibrad ka badan 10 sano u leh warshadaha. Waxa uu shahaadada koowaad ee jaamacadda ka qaatay xisaabaadka iyo maaliyadda iyo maamulka ganacsiga. Hugh waxa uu jecel yahay waxbaridda waxana uu sameeyay hab waxbarid gaar ah oo ay fududahay in la raaco lana fahmo. Aqoontiisa khabiirka ah ee Excel waxay ka caawisay kumanaan arday iyo xirfadlayaal adduunka oo dhan ah inay horumariyaan xirfadahooda oo ay ku fiicnaadaan shaqadooda. Isaga oo u maraya balooggiisa, Hugh waxa uu aqoontiisa la wadaagaa adduunka, isaga oo siinaya casharro Excel ah oo bilaash ah iyo tababar online ah si uu uga caawiyo shakhsiyaadka iyo ganacsiyada in ay gaaraan awooddooda buuxda.