+ Reply to Thread
Results 1 to 3 of 3

Delete specific row for all worksheets

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    brasil
    MS-Off Ver
    Excel 2010
    Posts
    13

    Red face Delete specific row for all worksheets

    Hello all,

    I am trying to make a code to check for all my sheets in a workbook:

    If the cell A1 have the word REV. then i want this first Row to be deleted..

    The code goes throw all workbok, reading correctly this cell value but somehow is not deleting this specific cell.


    Sub apagar_linhaREV()

    Dim Cell As Range
    Dim Rng As Range
    Dim Source As Worksheet
    Dim wb As Object
    Dim ws As Worksheet

    Set wb = ActiveWorkbook

    For Each ws In Worksheets

    With ws

    Set Source = ws
    Set Rng = Source.Range("A1")

    For Each Cell In Rng
    If Cell = "REV." Then
    Cell.EntireRow.Delete
    Rows.Cells.Delete

    'MsgBox "Ola mundo"
    End If

    Next Cell

    End With

    Next ws

    End Sub

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Delete specific row for all worksheets

    far as I can tell, the line rows.cells.delete would get rid of everything. I would try:

    Sub delete_A1()
    dim ws
    for each ws in activeworkbook.sheets
    if ws.Range("A1") = "REV." then ws.rows(1).delete
    next ws
    end sub

  3. #3
    Registered User
    Join Date
    07-08-2013
    Location
    brasil
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Delete specific row for all worksheets

    Hi ragulduy!!

    It worked perfectly!!!


    I am new at this your writing is a new way for me , thanks,

    Do you think its something about version that rows.cells.delete is not working ?

    Regards!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to delete entire row if first cell of it is empty for specific range and worksheets
    By roshanvmech in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-01-2014, 12:36 PM
  2. Replies: 1
    Last Post: 11-30-2013, 06:37 AM
  3. Loop for adding specific worksheets in specific workbooks
    By pankaj8219 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-13-2013, 10:22 AM
  4. [SOLVED] Macro to delete all worksheets except for one with specific name
    By jaimealvarez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2012, 12:01 PM
  5. VB Code to delete specific Columns of a specific worksheet
    By akh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-22-2010, 09:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1