本文介绍了根据单元格值插入复制的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 以下vba代码(修改自此处)将在列E中值为0的任何行上方插入一个空行。而不是插入空行一个方法来复制该行为0并将其插入它自己上面?这个vba代码可以修改吗?The vba code below (modified from here) will insert a blank row above any row that has a value of "0" in column E. Instead of inserting a blank row, is there a way to copy the row with "0" and insert it above itself? Can this vba code be modified to do this?Sub BlankLine() Dim Col As Variant Dim BlankRows As Long Dim LastRow As Long Dim R As Long Dim StartRow As Long Col = "E" StartRow = 1 BlankRows = 1 LastRow = Cells(Rows.Count, Col).End(xlUp).Row Application.ScreenUpdating = False With ActiveSheetFor R = LastRow To StartRow + 1 Step -1If .Cells(R, Col) = "0" Then.Cells(R, Col).EntireRow.Insert Shift:=xlDownEnd IfNext REnd WithApplication.ScreenUpdating = TrueEnd Sub推荐答案只需添加此行.Cells(R, Col).EntireRow.Copy 行 这篇关于根据单元格值插入复制的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-18 18:51