if cell does not contain value skip then go to next code

Leksv0j

New Member
Joined
Sep 15, 2017
Messages
22
Hi
Would someone be able to help with the VBA code if cell does not contain "data" the go to next code?
Eg: skip cell does not contain "Asset" the go to next code cell contains "Same"?
I have the below code which I use to generate cell range contains "asset"
ActiveSheet.Range("$A$1:$AA$76").AutoFilter Field:=22, Criteria1:= _"=*Asset*", Operator:=xlAnd
''''' do stuff'''''''''''
i want the code above to if not found go to next code
Sub within_PO()
ActiveSheet.Range("$A$1:$AA$76").AutoFilter Field:=22, Criteria1:= _"=*Same*", Operator:=xlAnd
Thank you so much

<tbody>
</tbody>
 
My apologies, when i said
Don't understand that.
I was referring to the behavior of the macro, not to what you had said.


Re the 1000 rows, is that what you should have, or is that coming from what I asked you to do in post#19?
Or maybe both
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
ummm..nah. just used a sheet that has more than 76 rows to try the code that you give.as is said, some sheets have more or less than 76 rows.
 
Upvote 0
I'm only interested in the number of rows on the sheet that is being filtered.
Can you please let me know how many rows you should have & how many the suggestion I made in post#19 gave?
 
Upvote 0
ok-- lets have 100 rows

43 filtered as RED and 56 Automatic.

concern is only for 43 rows the RED. in column V i will have now 19 "Same Batch" & 0 "Asset" or 24 Blank Cells.

2.) no specific number of rows to have. only what i have to work for is the "Same BAtch" and "Asset in Column V.

thank you..
 
Upvote 0
ok-- lets have 100 rows
In order to help you any further I NEED to know this
1) EXACTLY how many unfiltered rows do you have in the sheet (not some wishywashy "lets have")
2) How many rows is the code I supplied saying you have, once again unfiltered.
 
Upvote 0
wishywashy.. :LOL:

i only mean " for example".. sorry for giving you headache.. Fluff. i hope i can explain to you clearly.

new data (rows) in the sheet is added every time it comes to my box. "IF" the initial sheet (fresh) contains 20 rows to be specific, no filter yet is needed on A1. this 20 rows will contains "Asset " or "Same Batch" in Column V which needs to be filtered by running the code * contains Asset or Same to do the specified code for each result. on the next submission, same sheet will be process but new data(rows) is added to this sheet (10,100, or more). then A1 column is now filtered and the initial 20 rows will have the automatic color on it. and the newly added rows will be the RED fonts which will be the visible cell only.so the A1 column will always or is always filtered because only the RED Fonts is the 1 needs to be processed.

hope this is little bit clearer. tnx.
 
Upvote 0
I understand what you're saying, but it is not helping me diagnose the problem.
Run this
Code:
Sub TASKSHEET()

    Dim UsdRws As Long
    Dim w As Workbook

    UsdRws = Cells.Find("*", After:=Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    MsgBox UsdRws
End Sub
What number does the message box give, & is that number the same as the last row of data?
One possible reason why the code is not working, is that UsdRws is giving the wrong value.
 
Upvote 0
I understand what you're saying, but it is not helping me diagnose the problem.
Run this
Code:
Sub TASKSHEET()

    Dim UsdRws As Long
    Dim w As Workbook

    UsdRws = Cells.Find("*", After:=Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    MsgBox UsdRws
End Sub
What number does the message box give, & is that number the same as the last row of data?
One possible reason why the code is not working, is that UsdRws is giving the wrong value.


shows 181 and yeah the same number as the last row of data.
 
Upvote 0
Do you have any merged cells?
Can you also confirm that the header roe is row 1
with data starting in row 2
 
Upvote 0
no i don't have any merged cells on the sheets

and yes row 1 is the header with data starting in row 2. (if not filtered in A1)
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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