Show only cells in Sheet B when similar to values out of Sheet A vba

tom_hh

New Member
Joined
Apr 25, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have an Excel Workbook with several sheets filled with products from different suppliers.
In Sheet A I have all products with names only from all suppliers with all products in Stock. Colum A is the running number of the product 1 - 50230
Sheet A:
running number | product number | supplier ID | product name | stock value

I can select only ONE supplier via a macro - this Macro filters for products of this supplier (based on supplier ID) where the stock value is >0
All other products will be hidden.

In Sheet B are way more product information stored.
Running number | product code | supplier ID | supplier name | product name | product description | Purchase price | margin | ...| ... | ... | ... until column AW

I would like to create a Macro which hides all rows between row 3 (above are headers) and 60.000 in Sheet B where the running number is not equal to the ones shown in Sheet A column A (starting from row 2)

I hope I described the problem in a way that you can understand.

Thanks in advance
Thomas
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hello tom_hh,
Even my native language is not english, I hope I understood your request and I hope, my answer matches (nearly, because it's a solution without vba) what you are looking for.

I would suggest to add in sheet B, in cell AX2 the header word "on stock" and in AX3:AX60000 I would use the formula:
=IFERROR(MATCH($A3;shtA!$A$2:$A$50230;0)>0;FALSE)

Then mark AX2, press the Data-Menu-Button and then press the Filter-Button. Now each Header-Entry in A2:AX2 has a small triangle in the right lower corner. when you press the corner, a selection menu will open. If you do so in AX2, you have to disable the value FALSE, and just the running numbers in shtB which are also listed in shtA will be visible, all other will be hidden.
No question, these filters can be handled by vba, also. it would look something like that in the end of this post.

BTW, if somebody has an idea, how to solve my problem (How to open files in VBA for excel on a "portable device" / "external device" / "mobile device"), I would appreciate a posted solution;)

Kind regards,
Berny

VBA Code:
Option Explicit

Sub ShowOnStock()
    Sheets("shtB").Range("$A$2:$AX$60000").AutoFilter Field:=50, Criteria1:="TRUE"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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