문제

How do I remove row from all sheets who is having values Id

all sheets are having Id row as position 2nd.

So I could I remove 2nd row from all excel sheets?

Please guide me and give me any link ?

thanks

below code working good but only for open sheet .

how do I loop through each sheets from workbook ?

 Sub demo()

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Open("C:\Users\ashish.fugat\Desktop\demo.xlsx")

i = 1

Do Until objExcel.Cells(i, 2).Value = ""
    If objExcel.Cells(i, 2).Value = "Id" Then
        Set objRange = objExcel.Cells(i, 2).EntireRow
        objRange.Delete
        i = i - 1
    End If
    i = i + 1
Loop
End Sub
도움이 되었습니까?

해결책

You can loop through all worksheets in a workbook using this:

Option Explicit
Sub LoopThroughWorksheets()

'declare a worksheet to loop through the workbook with
Dim SheetIdx As Worksheet

For Each SheetIdx In ThisWorkbook.Worksheets
    '
    'do stuff here
    '
    'for example, if you wanted to show the name of each sheet
    'in the workbook, you could add the following line:
    MsgBox (SheetIdx.Name)
Next SheetIdx

End Sub
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top