VBA to turn a row into values only (based on list item)

Rob_010101

Board Regular
Joined
Jul 24, 2017
Messages
198
Office Version
  1. 365
Platform
  1. Windows
Hello,

Column J has a data validation list with the following 3 options:

1. Pending
2. Fit for work
3. Not fit for work

I would like to add VBA which converts the row (from A to I) into values only (i.e converts any formulas into values) when "fit for work" or "not fit for work" is selected in the drop-down list.

I've given it a go myself by trying to copy bits out of other codes but it's all a mish-mash and I'm not skilled enough to get it to work.

Any help appreciated.

Rob
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Give this a try (in that worksheet's code module)

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
 
  Set Changed = Intersect(Target, Columns("J"))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      If InStr(1, c.Value, "fit", vbTextCompare) > 0 Then
        With c.EntireRow.Resize(, 9)
          .Value = .Value
        End With
      End If
    Next c
    Application.EnableEvents = True
  End If
End Sub
 
Upvote 0
Solution
Give this a try (in that worksheet's code module)

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
 
  Set Changed = Intersect(Target, Columns("J"))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      If InStr(1, c.Value, "fit", vbTextCompare) > 0 Then
        With c.EntireRow.Resize(, 9)
          .Value = .Value
        End With
      End If
    Next c
    Application.EnableEvents = True
  End If
End Sub
That's resolved it, thanks for your help Peter
Much appreciated
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,174
Members
452,615
Latest member
bogeys2birdies

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