[英]I want to do look up on excel file to add new row in excel file in all sheet
I have one excel file with 100 sheets
我有一个
100 sheets
Excel文件
My problem is I want to do 我的问题是我想做
I want to check if I found "Name" In any "Attribute" column.
我想检查是否在任何“属性”列中找到“名称”。
Then Add new row of record "DisplayName"
with same values what "Name"
having but "IsMandatory"
is "N"
然后添加具有相同值的记录
"DisplayName"
新行,其中"Name"
具有但"IsMandatory"
为"N"
There are 400 sheets where I need to check and insert new row if I found "Name" in "Attribute" column 如果在“属性”列中找到“名称”,则需要检查400张纸并插入新行
Please give me idea . 请给我个主意。 How can I do it using excel lookup or pivot technique.
如何使用Excel查找或数据透视技术来做到这一点。 ?
?
Sub Test()
Dim curWorkbook As Workbook
Dim rnge As Range
Dim pasteCell As Integer
Set curWorkbook = ThisWorkbook
For Each wrkSheet In curWorkbook.Worksheets
wrkSheet.Activate
pasteCell = Range("A1").End(xlDown).Row + 1
wrkSheet.Range("A:A").Select
Set rnge = Selection.Find(What:="Name", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If rnge Is Nothing Then
'//Do Nothing
Else
wrkSheet.Range("A" & rnge.Row & ":D" & rnge.Row).Copy _
Destination:=wrkSheet.Range("A" & pasteCell & ":D" & pasteCell)
wrkSheet.Range("A" & pasteCell).Value = "Display Name"
wrkSheet.Range("C" & pasteCell).Value = "N"
Set rnge = Nothing
End If
wrkSheet.Range("A1").Select
Next
End Sub
I am assuming the column references will remain same (A:D). 我假设列引用将保持不变(A:D)。 If the columns will change in each individual sheet, you will have first find the correct column in the worksheet and then search for "Name" attribute in that column.
如果每个工作表中的列都会更改,则您将首先在工作表中找到正确的列,然后在该列中搜索“名称”属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.