If condition not found, continue Sub

excel01noob

Board Regular
Joined
Aug 5, 2019
Messages
93
Office Version
  1. 365
  2. 2016
Hi

I have this sub-procedure created.
As we export some date into excel and that data always have a row at the end with "query executed timestamp" I want to be able to manipulate the date after.

the below works if I have the "query" word in the data but how do I tell the sub to continue to other procedures if that word is not present ?



Sub word_query()



Dim queryword As String



queryword = "query"



If Cells.Find(What:=queryword).Activate Then



ActiveCell.EntireRow.Select

Selection.Delete



End If



Cells.EntireColumn.AutoFit



Range("A1").Select

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
VBA Code:
Sub word_query()

Dim queryword As String

queryword = "query"

If Cells.Find(What:=queryword).Activate Then
    ActiveCell.EntireRow.Delete
Else
'Do your other thing here
End If

Cells.EntireColumn.AutoFit

Range("A1").Select

End Sub
 
Upvote 0
ran into some issues.
This is what I have now

Sub Pay_auto_2()

Dim queryword As String

queryword = "query"

If Cells.Find(What:=queryword).Activate Then

ActiveCell.EntireRow.Delete

Else

'Do your other thing here

Cells.Find(What:="Net Amount").Activate
Selection.Offset(1, 0).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select

With Selection

.NumberFormat = "General"
.Value = .Value
.Style = "comma"

End With

++++++++++++++++++++++
in some occasions the "net amount" column would have the word MULTI in some cells.
Of course, I cannot convert this into number but the procedure gives me an error I suppose due to that.
How can I include this in the Sub:

If Multi is present, skip the conversion into numbers and continue with other cells in the column
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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