PDA

View Full Version : clear contents formula



jasman
02-09-2011, 04:09 AM
hi i have the below formula which looks at column AU and if it has a value then deleted contents of AQ and AR, but it works only for row 4.

If Target.AddressLocal = Range("AU4").AddressLocal Then
Range("AQ4:AR4").ClearContents
End If

How can I apply this to all rows below 4 aswell?

thanks

CharlesH
02-09-2011, 12:30 PM
Hi,

You will need to get the last row of data in order to do what you want.



Dim Lrow as Long
Lrow = Sheets("Your Sheet name").Range("AR65536").End(XLUP).Row
If Target.AddressLocal = Range("AU4").AddressLocal Then
Range("AQ4:AR" & Lrow).ClearContents
End If

tepkool01
02-09-2011, 12:47 PM
Ah great. Thanks