• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Dynamic Delete VBA Code Not Working as required

Manan

New Member
Hi All ,

I am trying to Delete the Selection from H14:O(xx) where xx represents the variable number of Columns, depends upon the number of rows get populated. I have written below code but this is deleteing the wrong selection of Data. Can someone look and help me , waht i am doing wrong.
Code:
Sub DynDel()
'
' DynDel Macro
'
'
  
  Range("H14:O" & Cells(Rows.Count, 1).End(xlUp).Row).Select
  Range(Selection, Selection.End(xlDown)).Select
  Selection.ClearContents
End Sub
 
Replace your 3 lines with a single line:
Code:
  Range("H14:O" & Cells(Rows.Count, 8).End(xlUp).Row).ClearContents
 
Back
Top