Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default clear contents of cell

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default clear contents of cell

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" skrev i meddelelsen
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default clear contents of cell

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default clear contents of cell

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to clear range contents when cell contents are changed by us Steve E Excel Programming 12 February 22nd 07 09:09 PM
Clear Cell Contents workerboy[_4_] Excel Programming 2 August 10th 06 06:29 PM
VBA Clear Cell Contents towl[_3_] Excel Programming 4 October 20th 05 05:14 PM
vb to clear cell contents RichT New Users to Excel 6 June 27th 05 08:26 AM
Clear cell contents with a button KFC / A&W Boy Excel Worksheet Functions 1 March 7th 05 09:39 AM


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"