Բաց թողնել հիմնական բովանդակությունը

Ինչպե՞ս Excel- ում բջջային արժեքի հիման վրա ավտոմատ ներդնել շարքը:

doc-insert-row-based-based-value-1
Ենթադրենք, որ դուք ունեք տվյալների մի շարք, և դուք ցանկանում եք ավտոմատ կերպով տեղադրել Excel- ում որոշակի արժեքի վերևից կամ ներքևից դատարկ տողեր, օրինակ `ավտոմատ ներդնել տողեր զրոյական արժեքից ցածր, ինչպես ցույց է տրված նկարում: Excel- ում ոչ մի ուղի չկա, որը կարող է լուծել այս խնդիրը, բայց ես կարող եմ ձեզ համար ներկայացնել մակրո կոդ ՝ Excel- ում որոշակի արժեքի հիման վրա տողեր ավտոմատ տեղադրելու համար:
Տեղադրեք տողը ներքևում `հիմնվելով VBA- ի բջջային արժեքի վրա

Տեղադրեք վերևում շարքը ՝ հիմնված բջջային արժեքի վրա Kutools- ի համար Excel- ի լավ գաղափար 3

VBA գործարկմամբ բջիջի արժեքի հիման վրա տող տեղադրելու համար կատարեք հետևյալ քայլերը.

1. Մամուլ Alt + F11 ստեղները միաժամանակ, և ա Microsoft Visual Basic հավելվածների համար պատուհանը դուրս է գալիս:

2: սեղմեք Տեղադրել > Մոդուլներ, ապա կպցրեք ներքևում գտնվող VBA կոդի վրա ՝ դուրս գալու համար Մոդուլներ պատուհան.

VBA. Ներդիր տողը ներքևում ՝ ելնելով բջջային արժեքից:

Sub BlankLine()
	'Updateby20150203
	Dim Rng As Range
	Dim WorkRng As Range
	On Error Resume Next
	xTitleId                   = "KutoolsforExcel"
	Set WorkRng                = Application.Selection
	Set WorkRng                = Application.InputBox("Range", xTitleId, WorkRng.Address, Type: = 8)
	Set WorkRng                = WorkRng.Columns(1)
	xLastRow                   = WorkRng.Rows.Count
	Application.ScreenUpdating = False
	For xRowIndex = xLastRow To 1 Step - 1
		Set Rng                   = WorkRng.Range("A" & xRowIndex)
		If Rng.Value = "0" Then
			Rng.Offset(1, 0).EntireRow.Insert Shift: = xlDown
		End If
	Next
	Application.ScreenUpdating = True
End Sub

3: սեղմեք F5 բանալին կամ Վազում կոճակը, դուրս է գալիս երկխոսություն և ընտրում սյունը զրո: Տեսեք,
doc-insert-row-based-based-value-2

4: սեղմեք OK, Դրանից հետո դատարկ տողերը կտեղադրվեն զրոյական արժեքից ցածր:
doc-insert-row-based-based-value-3

Ակնարկ:

1. Եթե ցանկանում եք տողեր տեղադրել այլ արժեքի հիման վրա, կարող եք փոխել 0 ցանկացած արժեքի, որը ցանկանում եք VBA- ում. Եթե ​​Rng.Value = "0" ապա.

2. Եթե ցանկանում եք զրոյից կամ այլ արժեքից բարձր տողեր տեղադրել, կարող եք օգտագործել ստորև նշված vba կոդը:

VBA. Տեղադրեք տողը զրոյական արժեքից վեր.

Sub BlankLine()
	'Updateby20150203
	Dim Rng As Range
	Dim WorkRng As Range
	On Error Resume Next
	xTitleId                   = "KutoolsforExcel"
	Set WorkRng                = Application.Selection
	Set WorkRng                = Application.InputBox("Range", xTitleId, WorkRng.Address, Type: = 8)
	Set WorkRng                = WorkRng.Columns(1)
	xLastRow                   = WorkRng.Rows.Count
	Application.ScreenUpdating = False
	For xRowIndex = xLastRow To 1 Step - 1
		Set Rng                   = WorkRng.Range("A" & xRowIndex)
		If Rng.Value = "0" Then
			Rng.EntireRow.Insert Shift: = xlDown
		End If
	Next
	Application.ScreenUpdating = True
End Sub

doc-insert-row-based-based-value-4


Եթե ​​ծանոթ չեք VBA- ին, կարող եք փորձել Excel- ի համար նախատեսված գործիքներ's Ընտրեք հատուկ բջիջներ օգտակարություն, ապա վերևում շարքեր տեղադրեք:

Excel- ի համար նախատեսված գործիքներ, ավելի քան 300 հարմար գործառույթներ, ավելի հեշտացնում է ձեր գործերը: 

Տեղադրելուց հետո Excel- ի համար նախատեսված գործիքներ, խնդրում ենք վարվել ինչպես ստորև ՝(Անվճար ներբեռնեք Kutools- ի համար Excel- ը հիմա!)

1. Ընտրեք ցուցակը, որից ուզում եք պարզել կոնկրետ բջիջները և կտտացնել Կուտոլս > ընտրել > Ընտրեք հատուկ բջիջներ, Տեսեք,
doc ներդիրի տող, որը հիմնված է 9 արժեքի վրա

2. Բացվող պատուհանում ստուգեք Ամբողջ շարքը տարբերակը, ապա անցեք ընտրելու հավասար - ից Հատուկ տեսակ ցուցակը, ապա մուտքագրեք ճիշտ տուփի տուփում այն ​​արժեքը, որը ցանկանում եք գտնել: Տեսեք,
doc ներդիրի տող, որը հիմնված է 6 արժեքի վրա

3: սեղմեք Ok, և դուրս է գալիս երկխոսություն ՝ ընտրված շարքերի քանակը հիշեցնելու համար, պարզապես փակեք այն:

4. Տեղադրեք կուրսորը մեկ ընտրված շարքում և ընտրելու համար սեղմեք աջ Տեղադրել համատեքստային ընտրացանկից: Տեսեք,
doc ներդիրի տող, որը հիմնված է 7 արժեքի վրա

Այժմ տողերը տեղադրվում են վերևում ՝ հիմնվելով որոշակի արժեքի վրա:
doc ներդիրի տող, որը հիմնված է 8 արժեքի վրա


Հարաբերական հոդվածներ:

Գրասենյակի արտադրողականության լավագույն գործիքները

🤖 Kutools AI օգնականՀեղափոխություն կատարել տվյալների վերլուծության հիման վրա՝ Խելացի կատարում   |  Ստեղծեք ծածկագիր  |  Ստեղծեք հատուկ բանաձևեր  |  Վերլուծել տվյալները և ստեղծել գծապատկերներ  |  Invoke Kutools-ի գործառույթները...
Հանրաճանաչ հատկություններ: Գտեք, ընդգծեք կամ նույնականացրեք կրկնօրինակները   |  Deleteնջել դատարկ շարքերը   |  Միավորել սյունակները կամ բջիջները՝ առանց տվյալների կորստի   |   Կլոր առանց բանաձևի ...
Super Փնտրել: Բազմաթիվ չափանիշների VLookup    Բազմակի արժեք VLookup  |   VLookup բազմաթիվ թերթերում   |   Fuzzy Փնտրել ....
Ընդլայնված բացվող ցուցակ: Արագ ստեղծեք բացվող ցուցակը   |  Կախված բացվող ցուցակ   |  Բազմակի ընտրություն Drop Down ցուցակ ....
Սյունակի կառավարիչ: Ավելացրեք որոշակի քանակությամբ սյունակներ  |  Տեղափոխել սյունակները  |  Փոխարկել թաքնված սյունակների տեսանելիության կարգավիճակը  |  Համեմատեք միջակայքերը և սյունակները ...
Առանձնահատկություններ: Ցանցի կենտրոնացում   |  Դիզայնի տեսք   |   Մեծ Formula Bar    Աշխատանքային գրքույկի և թերթիկների կառավարիչ   |  Ռեսուրսների գրադարան (Ավտոմատ տեքստ)   |  Ամսաթիվ ընտրող   |  Միավորել աշխատանքային թերթերը   |  Գաղտնագրել/գաղտնազերծել բջիջները    Ուղարկեք նամակներ ըստ ցանկի   |  Սուպեր զտիչ   |   Հատուկ զտիչ (զտել թավ/շեղ/շեղված...) ...
Լավագույն 15 գործիքների հավաքածու12 Տեքստ Գործիքներ (Ավելացրեք տեքստ, Հեռացնել նիշերը, ...)   |   50+ Աղյուսակ Տեսակներ (Գանտի աղյուսակը, ...)   |   40+ Գործնական Բանաձեւեր (Հաշվարկել տարիքը ՝ ելնելով ծննդյան տարեդարձից, ...)   |   19 միացում Գործիքներ (Տեղադրեք QR կոդ, Տեղադրեք նկար ուղուց, ...)   |   12 Փոխարկում Գործիքներ (Բառեր համարներ, Արտարժույթի փոխակերպումը, ...)   |   7 Միաձուլում և պառակտում Գործիքներ (Ընդլայնված կոմբինատ տողեր, Պառակտված բջիջներ, ...)   |   ... եւ ավելին

Լրացրեք ձեր Excel-ի հմտությունները Kutools-ի հետ Excel-ի համար և փորձեք արդյունավետությունը, ինչպես երբեք: Kutools-ը Excel-ի համար առաջարկում է ավելի քան 300 առաջադեմ առանձնահատկություններ՝ արտադրողականությունը բարձրացնելու և ժամանակ խնայելու համար:  Սեղմեք այստեղ՝ Ձեզ ամենաշատ անհրաժեշտ հատկանիշը ստանալու համար...

Նկարագրություն


Office Tab- ը Tabbed ինտերֆեյսը բերում է Office, և ձեր աշխատանքը շատ ավելի դյուրին դարձրեք

  • Միացնել ներդիրներով խմբագրումը և ընթերցումը Word, Excel, PowerPoint- ով, Հրատարակիչ, Access, Visio և Project:
  • Բացեք և ստեղծեք բազմաթիվ փաստաթղթեր նույն պատուհանի նոր ներդիրներում, այլ ոչ թե նոր պատուհաններում:
  • Բարձրացնում է ձեր արտադրողականությունը 50%-ով և նվազեցնում մկնիկի հարյուրավոր սեղմումները ձեզ համար ամեն օր:
Comments (43)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hola mira necesito agregar filas en blanco automaticamente cuando se me produce desbordamiento en diferentes filas y probe varias formas y no lo toma.
me podrias ayudar?desde ya gracias
This comment was minimized by the moderator on the site
need help with a code. I am trying insert rows based on value in another cell on another worksheet (same workbook). then automatically update that number if blank cell if filled. so basically worksheet 1 has, column A all time starts from 4 am to 10 pm. Column B is employee name. Worksheet 2 has time starts in column A and available shifts for that time start in column B. I need to find a way to automatically insert blank row at last time start ie 4 am in worksheet 1 if worksheet 2 has ie. 1 available shift to pick up for 4 am. then update the number in worksheet 2 if the cell if fill at a later time. Is this possible?
This comment was minimized by the moderator on the site
Gracias por tu macro, he utilizado la primera y me funciona perfectamente.
Necesitaría a la vez de generar una fila en blanco debajo de otra dependiendo de un valor, que esa linea se copie en la que se ha generado en blanco.
Me seria de gran ayuda.
This comment was minimized by the moderator on the site
Can anyone suggest how to do this with adding 1 row for any number grater than 0?
This comment was minimized by the moderator on the site
Hi, Jordan, change the script: If Rng.Value = "0" Then to If Rng.Value > "0" Then
in the vba of the article.
This comment was minimized by the moderator on the site
Instead of a dialogue box that pops up asking which cells it should look at, how can I instead just require a preset range? In this case I want it to always run it for E3 to E800. Thanks!
This comment was minimized by the moderator on the site
Hi, Christopher M, try below code, it take A1:A10 as an example, just change it as you need.
Sub BlankLine()
'ByExtendoffice
Dim Rng As Range

Dim WorkRng As Range

Dim xRngI As Range

On Error Resume Next

xTitleId = "KutoolsforExcel"

Set WorkRng = Application.Range("A1:A10") 'Change the range as you need

Set WorkRng = WorkRng.Columns(1)

xLastRow = WorkRng.Rows.Count

Application.ScreenUpdating = False

For xRowIndex = xLastRow To 1 Step -1

  Set Rng = WorkRng.Range("A" & xRowIndex)

  If Rng.Value = "Node1" Then

    Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown

    Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown

    Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown

    Rng.Offset(1, 0).Value = "Scanner"

    Rng.Offset(2, 0).Value = "Printer"

    Rng.Offset(3, 0).Value = "CD"

  End If

Next

Application.ScreenUpdating = True

End Sub
This comment was minimized by the moderator on the site
I need to add particular rows with values in them for specific cell contents, but not sure how to do so without having to manually do for over 3800+ lines

Ex: A1 = Node1
I need to have a row inserted and it to enter the value Scanner
Enter another row and enter the value Printer
another row with value CD.
Etc
This comment was minimized by the moderator on the site
Hi, Chris, here is a VBA can help you to automatically insert three rows (Scanner, Printer, CD) when the value equal to Node1.
Sub BlankLine()
'ByExtendoffice
Dim Rng As Range

Dim WorkRng As Range

Dim xRngI As Range

On Error Resume Next

xTitleId = "KutoolsforExcel"

Set WorkRng = Application.Selection

Set WorkRng = Application.InputBox("Select a range", xTitleId, WorkRng.Address, Type:=8)

Set WorkRng = WorkRng.Columns(1)

xLastRow = WorkRng.Rows.Count

Application.ScreenUpdating = False

For xRowIndex = xLastRow To 1 Step -1

  Set Rng = WorkRng.Range("A" & xRowIndex)

  If Rng.Value = "Node1" Then

    Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown

    Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown

    Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown

    Rng.Offset(1, 0).Value = "Scanner"

    Rng.Offset(2, 0).Value = "Printer"

    Rng.Offset(3, 0).Value = "CD"

  End If

Next

Application.ScreenUpdating = True

End Sub

Please let me know if works for you.
This comment was minimized by the moderator on the site
Hi,
Can this marco be used/altered for colored cells?
I need to insert at least 10 rows above end of the each series which are colored.
Thx!
This comment was minimized by the moderator on the site
please help mei have a data.i have one month time data, in that i have to insert a empty rows according to the escape time
This comment was minimized by the moderator on the site
Hi, hr.babu08, sorry the reply is late. I guess you want to insert blank rows or make a mark for the missing sequence data, if so, you can try Kutools for Excel's Find Missing Sequence Number feature.Here is the tutorial about the feature: https://www.extendoffice.com/product/kutools-for-excel/excel-find-missing-numbers-in-sequence.htmlIf you want other methods on inserting blank rows for missing sequence, please visit:https://www.extendoffice.com/documents/excel/3522-excel-find-missing-dates.html</div>;
This comment was minimized by the moderator on the site
Hello. The macro works for me but is there a way to always have the range/parameters set always to column J without the input box coming up at all? I would like it to skip the step of the input box coming up. Also, I have made sure that directly before this macro that the last line of my previous macro is Range("J:J").Select to make sure the whole J column is already selected.
This is what I have been using so far.

Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "Click OK to Continue"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.Columns(1)
SendKeys "~"
xLastRow = WorkRng.Rows.Count
Application.ScreenUpdating = False
For xRowIndex = xLastRow To 1 Step -1
Set Rng = WorkRng.Range("A" & xRowIndex)
If Rng.Value = "New GMS Line" Then
Rng.EntireRow.Insert Shift:=xlDown
End If
Next


I Have tried experimenting using the SendKeys "~" command between some of the steps to try and get it to press enter automatically when the input box comes up but that hasn't worked either. I wasn't sure where exactly to use the SendKeys command in the macro or if it would even work with an input box!
This comment was minimized by the moderator on the site
Many thanks for this, really a tremendous time saver. Would it be possible to add some code which allows me to insert some text in the new row. For example i'm inserting new rows based on target value 'x', then i want to add text value 'y' in the cell below target value 'x'. Is this possible?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations