简体   繁体   English

我想在Excel文件中查找以在所有工作表的Excel文件中添加新行

[英]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.

相关问题 EXCEL:在工作表的第一行中查找今天的日期 - EXCEL: Look up today's date in the first row of a sheet 如何从 a.txt 文件中获取文本并将其写入同一个 excel 文件的新工作表中 - How do I get the text from a .txt file and write it in a new sheet in the same excel file 想要将多个Excel文件的每张纸的第一行复制到另一个Excel文件 - Want to copy first row of each sheet of multiple Excel files to another Excel file 我想在 pandas 中使用.to_excel 创建的 excel 中添加一个新工作表 - I want to add a new sheet in an excel created using .to_excel in pandas 我想相对于列对表格中 excel 文件中存在的数据进行排序。 (excel文件有多张) - I want to sort data present in excel file in sheet with respect to column. (The excel file has multiple sheets) 我想在 R 中使用 writexl package 时添加新工作表并避免替换 excel 中的现有工作表 - I want to add a new sheet and avoid replacing the existing sheet in excel while using the writexl package in R 如何为文件夹中的每个 csv 文件在 excel 中创建一个新工作表 - How do I create a new sheet in excel for every csv file I have in my folder 如何使用 Matlab 中的 excel 表中的信息读取一个文件夹中的所有.wav 音频文件? - How do I read all the .wav audio file in one folder using information from an excel sheet in Matlab? 在另一个Excel工作表上查找值 - Look up value, on another Excel sheet Excel countif不会查找其他工作表 - Excel countif does not look up a different sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM