PC Review


Reply
Thread Tools Rate Thread

clear contents of cell

 
 
Curt
Guest
Posts: n/a
 
      1st Nov 2009
trying to have when an entry in row column (L) is made
clear contents of same row column (P)
have following but doesn't clear as wanted
thanks

Dim lr As Long
lr = Cells(Rows.Count, 200).End(xlUp).row
If Not Intersect(Target, range("L200:L" & lr)) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value >= 10 Then
Sheets("data").range("P" & Target.row).ClearContents
End If
End If
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      1st Nov 2009
Hi

You are trying to calculate 'lr' based on column 200, which I guess is not
what you want.

Dim lr As Long
lr = Cells(Rows.Count, "L").End(xlUp).Row
If Not Intersect(Target, Range("L200:L" & lr)) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value >= 10 Then
Application.EnableEvents = False
Sheets("data").Range("P" & Target.Row).ClearContents
Application.EnableEvents = True
End If
End If

Regards,
Per

"Curt" <(E-Mail Removed)> skrev i meddelelsen
news:53197AB1-0440-4533-80FE-(E-Mail Removed)...
> trying to have when an entry in row column (L) is made
> clear contents of same row column (P)
> have following but doesn't clear as wanted
> thanks
>
> Dim lr As Long
> lr = Cells(Rows.Count, 200).End(xlUp).row
> If Not Intersect(Target, range("L200:L" & lr)) Is Nothing Then
> If IsNumeric(Target.Value) And Target.Value >= 10 Then
> Sheets("data").range("P" & Target.row).ClearContents
> End If
> End If


 
Reply With Quote
 
Atishoo
Guest
Posts: n/a
 
      1st Nov 2009
Change your clear contents to .value=""

"Curt" wrote:

> trying to have when an entry in row column (L) is made
> clear contents of same row column (P)
> have following but doesn't clear as wanted
> thanks
>
> Dim lr As Long
> lr = Cells(Rows.Count, 200).End(xlUp).row
> If Not Intersect(Target, range("L200:L" & lr)) Is Nothing Then
> If IsNumeric(Target.Value) And Target.Value >= 10 Then
> Sheets("data").range("P" & Target.row).ClearContents
> End If
> End If

 
Reply With Quote
 
Atishoo
Guest
Posts: n/a
 
      1st Nov 2009
You may also want to apply your sub to the last selected cell rather than the
active cell so that it will apply its action to the cell you have just filled.
I use the following to retrieve the address of the previous cell.

Dim LastSelected As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
LastSelected = Target.Address
End Sub

Note that Dim lastselected as string appears above private sub worksheet
selection change

"Atishoo" wrote:

> Change your clear contents to .value=""
>
> "Curt" wrote:
>
> > trying to have when an entry in row column (L) is made
> > clear contents of same row column (P)
> > have following but doesn't clear as wanted
> > thanks
> >
> > Dim lr As Long
> > lr = Cells(Rows.Count, 200).End(xlUp).row
> > If Not Intersect(Target, range("L200:L" & lr)) Is Nothing Then
> > If IsNumeric(Target.Value) And Target.Value >= 10 Then
> > Sheets("data").range("P" & Target.row).ClearContents
> > End If
> > End If

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear Cell Contents based on Criteria of another cell CK Microsoft Excel Programming 10 21st May 2009 04:07 PM
Macro to clear range contents when cell contents are changed by us =?Utf-8?B?U3RldmUgRQ==?= Microsoft Excel Programming 12 22nd Feb 2007 09:09 PM
Macro to Clear Cell Contents based on Cell Value in another Sheet CH Microsoft Excel Discussion 4 26th Jan 2007 08:37 PM
Clear Cell Contents workerboy Microsoft Excel Programming 2 10th Aug 2006 06:29 PM
Type into one cell and automatically clear contents in another cell Bo Microsoft Excel Programming 4 29th Sep 2003 06:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:30 PM.