Delete certain cells of active row

Solved/Closed
Trowa - Sep 25, 2009 at 08:56 AM
 tatosgr - Mar 5, 2010 at 09:58 PM
Hello,

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?

Best regards,
Trowa

4 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Sep 25, 2009 at 08:32 PM
try
cells(r,5) and cells(r,7)
3
Thanks Venkat, works like a charm.
0
How do you declare r ? Variant? integer? range?
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Mar 5, 2010 at 02:43 PM
Long would be the safest. It is being used to handle row numbers.
0
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Mar 5, 2010 at 09:53 PM
[quote]
How do you declare r ? Variant? integer? range?[/quote]

something like this
dim r as range, j as integer, k as long,m(leave it blank then it is variant)
0
Thanks rizvisa1 and venkat1926 .. I'd try both (waiting for errors or bugs :P) .. If I have any doubt, I'll stop by again :)

Thanks again :)
0