Need help to update Macro

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,134
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
Sub test7778() 'Good but using Somewhere else'

Dim lastRow, y, x As Long

lastRow = ActiveSheet.Range("F" & Rows.count).End(xlUp).Row

For y = lastRow To 1 Step -1 'use 1 if data starts on row 1, use 2 if you have headers in row 1 with data on row 2.
   
   If InStr(Range("F" & y), "Trim") = 0 And Range("F" & y) <> "" Then
        Range("F" & y).EntireRow.Delete
   End If
    
    
Next y

End Sub

HI everytime i have to run this code above i have to change below. Now it says "Trim" if i have to change it to "Money" i have to go into code all the time to do so and i do this alot.

I need it updated so when i am on the sheet. I can just type in column K2 the name then run the macro. Instead of me always opening code and changing it. Can anyone help me with this thanks.

VBA Code:
If InStr(Range("F" & y), "Trim") = 0 And Range("F" & y) <> "" Then
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Probably:
VBA Code:
If InStr(Range("F" & y), Range("K2").Value) = 0 And Range("F" & y) <> "" Then
 
Upvote 0
Solution

Forum statistics

Threads
1,225,479
Messages
6,185,229
Members
453,283
Latest member
Shortm88

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