Excel - Delete certain cells of active row

December 2016




Issue


I would like a code for the following:

Check which row is active/selected and then delete the data which is in the 5th and 7th column of that row.


I've tried the following:

Sub test() 
r = ActiveCell.Row 
Range(r, 5).ClearContents 
Range(r, 7).ClearContents 
End Sub 


Can someone help me out with this?

Solution


Try:
cells(r,5) and cells(r,7)

Note


Thanks to venka1926 for this tip on the forum.

Related :

This document entitled « Excel - Delete certain cells of active row » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.