VBA if Col B contains xxx then Col T value = 0

tezza

Active Member
Joined
Sep 10, 2006
Messages
375
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
  2. Web
Hi all

How do you code in VBA to check if Col B contains 'Unpaid' and if it does put a value of '0' in Col T?

TimesheetExtract.csv
BKLMNOPQRSTUVWXY
1Client First Name Client Last NameDate of CallCall Start TimeCall End TimeCall DurationMileageCommunity MileageStaff MileageTravel TimeRoundedBasicDom_careSpecialist TaskWeekendOfficeDC/On-Call
2 Training#########09:3012:303.003300000
3 Training#########13:0015:002.002200000
64 Training#########13:0015:002.002200000
65 Training Completed Online#########15:0016:001.001100000
66 Training Online Unpaid#########16:0017:001.001000000
Sheet1
Cell Formulas
RangeFormula
B1:B3,B64:B66B1=TS!B1&" "&TS!C1
N2:N3,N64:N66N2=ROUND(-((INT(TS!Z2)-TS!Z2)*24),2)
S2:S3,S64:S66S2=CEILING(N2,0.25)
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Sub UnpaidFill()
'Get last row of column b

lastr = Cells(Rows.Count, 2).End(xlUp).Row
For r = 2 To lastr
'lcase is used to make the comparison case insensitive
If LCase(Cells(r, 2).Value) Like "*unpaid*" Then Cells(r, 20).Value = 0

Next


End Sub
 
Upvote 0
Sub UnpaidFill()
'Get last row of column b

lastr = Cells(Rows.Count, 2).End(xlUp).Row
For r = 2 To lastr
'lcase is used to make the comparison case insensitive
If LCase(Cells(r, 2).Value) Like "*unpaid*" Then Cells(r, 20).Value = 0

Next


End Sub
Thank you, I can work with that :)
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,123,009
Members
449,093
Latest member
ikke

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