If cannot find string...set to 0

NewbieMan

New Member
Joined
Nov 25, 2017
Messages
33
Hi,

Stuck writing the IF statement for the following code

Code:
'Total Wins
findrow = Range("A:A").Find("Career").Offset(0, 4).Select
ActiveCell.Copy
Range("T5").PasteSpecial
findrow2 = Range("A:A").Find("2017-18").Offset(0, 4).Select
ActiveCell.Copy
Range("T4").PasteSpecial
Range("T3").Value = Range("T5").Value - Range("T4").Value

Could someone help to rewrite this so that IF the string 2017-18 cannot be found, then sub in the value of 0 "zero" for cell T4 otherwise continue as is. Right now it kicks out an error.

Thanks in advance
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
A bit of a workaround, would this suit?

Code:
findrow = Range("A:A").Find("Career").Offset(0, 4).SelectActiveCell.Copy
Range("T5").PasteSpecial
On Error Resume Next
findrow2 = Range("A:A").Find("2017-18").Offset(0, 4).Select
If findrow2 <> "" Then
ActiveCell.Copy
Range("T4").PasteSpecial
Else
Range("T4").Value = 0
End If
Range("T3").Value = Range("T5").Value - Range("T4").Value
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

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