Consulting

Results 1 to 10 of 10

Thread: DELETING SYMBOLS

  1. #1
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    DELETING SYMBOLS

    Hi,

    how can I delete symbols in the row 52 and 53 in the attached file ?

    regards

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Run this bit of code.

    [vba] For Each shp In ActiveSheet.Shapes
    shp.Delete
    Next shp
    [/vba]

  3. #3
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    deleting shape

    can I delete without code ?


    with code it deletes all of them not only the shape in row 52 and 53

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try
    [VBA]Sub DelShapes()
    For Each shp In ActiveSheet.Shapes
    If shp.TopLeftCell.Row = 52 Or shp.TopLeftCell.Row = 53 Then
    shp.Delete
    End If
    Next shp
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    deleting shapes

    hi,

    runtime error 1004

    application-defined or object-defined error

    what is the problem ?

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    On what line does the error occur?
    Here's a slight modification to help show where the shapes are found
    [VBA]Option Explicit

    Sub DelShapes()
    Dim shp As Shape
    MsgBox ActiveSheet.Shapes.Count
    For Each shp In ActiveSheet.Shapes
    shp.TopLeftCell.Interior.ColorIndex = 7
    If shp.TopLeftCell.Row = 52 Or shp.TopLeftCell.Row = 53 _
    Or shp.TopLeftCell.Row = 54 Then
    shp.TopLeftCell.Interior.ColorIndex = 6
    shp.Delete
    End If
    Next shp
    MsgBox ActiveSheet.Shapes.Count
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    deleting symbols

    hi,

    B53 becomes yellow.message says 26 then gives same error.
    error line is shp.Delete

    regards

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I can't replicate the error. The yellow cell shows a shape has been found. You could try changing the code a bit to see in any shapes are deleted.
    [VBA]shp.TopLeftCell.Interior.ColorIndex = 6
    MsgBox ActiveSheet.Shapes.Count
    shp.Delete
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    deleting symbols

    hi,

    I could not solve the problem. please check the attached file. I want to delete the shapes in 52 and 53

    regards

  10. #10
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try unprotecting the sheet.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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