Clear Contents In VB

ryderlane

New Member
Joined
Nov 2, 2018
Messages
7
Hello all!

New to VB and have a question.

I'm trying clear contents in one cell once a drop down is selected. I select a drop down that displays pricing in the the "System Pump" and "VFD Pricing " Cells.
What I'd like it to do is clear just the contents in (VFD Pricing $) once "NO" is selected in another drop down.

Can anyone help?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
.
Paste in the sheet module :

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim ws As Worksheet
    Dim lRow As Long
    Set ws = ThisWorkbook.Sheets("Sheet1")
    Dim i As Integer


With ws
    lRow = .Range("A" & .Rows.Count).End(xlUp).Row
    For i = 1 To lRow
        If .Cells(i, 1) = "No" Then
            .Cells(i, 2) = ""
        End If
    Next i
End With
End Sub

A
B
1
YesB1
2
YesB2
3
YesB3
4
YesB4
5
YesB5
6
YesB6
7
YesB7
8
YesB8
9
YesB9
10
YesB10
11
YesB11
12
YesB12
 
Upvote 0
Assuming you will be entering "No" into column A

Try this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  11/3/2018  1:12:34 AM  EDT
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Value = "No" Then Target.Offset(, 1).Value = ""
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,565
Messages
6,120,254
Members
448,952
Latest member
kjurney

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