Private Sub Worksheet_SelectionChange PROBLEM

Small Paul

Board Regular
Joined
Jun 28, 2018
Messages
118
Hi
Please could somebody help with an issue I am currently experiencing?

I have the following code:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)    Dim thisrow As Long
    If Target.Column = 3 Then
        thisrow = Target.Row
        Range("B" & thisrow) = Range("B" & thisrow) + Range("C" & thisrow)
  


    If Target.Column = 3 Then
        thisrow = Target.Row
        Range("D" & thisrow) = Range("D" & thisrow) + Range("C" & thisrow)
        Range("C" & thisrow).ClearContents
    
    
    If Target.Column = 12 Then
        thisrow = Target.Row
        Range("M" & thisrow) = Range("L" & thisrow)
        Range("L" & thisrow).ClearContents




    End If
    End If
    End If


    
End Sub
The first 2 sections work fine. Simply type the required 'figure' in column C, they ADD on to existing data (as necessary) and the figure in column C is deleted. On the back of that, the cells are then copied via VLookups to a separate sheet.

The third section does not work however. I type the 'text' into column L and via an =IF it shows in column O. Unfortunately, when I click on the cell in 'L', nothing happens. I need the 'value' to:
  • Show in column M (with seeming no formula behind it)
  • Clear in column L
  • Clear from column O (which equals L)

If anybody has any ideas it would be appreciated.

Best regards
Small Paul.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Intersect(Target, Range("C:C,L:L")) Is Nothing Then Exit Sub
    Select Case Target.Column
        Case Is = 3
            Range("B" & Target.Row) = Range("B" & Target.Row) + Range("C" & Target.Row)
            Range("D" & Target.Row) = Range("D" & Target.Row) + Range("C" & Target.Row)
            Range("C" & Target.Row).ClearContents
        Case Is = 12
            Range("M" & Target.Row) = Range("L" & Target.Row)
            Range("L" & Target.Row).ClearContents
    End Select
End Sub
 
Upvote 0
Try
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   Dim thisrow As Long
   If Target.Column = 3 Then
      thisrow = Target.Row
      Range("B" & thisrow) = Range("B" & thisrow) + Range("C" & thisrow)
      Range("D" & thisrow) = Range("D" & thisrow) + Range("C" & thisrow)
      Range("C" & thisrow).ClearContents
   ElseIf Target.Column = 12 Then
      thisrow = Target.Row
      Range("M" & thisrow) = Range("L" & thisrow)
      Range("L" & thisrow).ClearContents
   End If
End Sub
 
Upvote 0
Fluff and mumps
Thank you so much for your help.
The first of the 2 options works great.
Small paul.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top