VBA code to gain data of selection

Navi_G

Board Regular
Joined
May 30, 2018
Messages
94
Office Version
  1. 2016
Platform
  1. Windows
Hi All Experts,
I am here with a problem. I have data sheet named "Cut Sheet" in which I have my data in columns "J:N" rows of this data could increase and decrease I want to extract data from that range in to "A:E" column I want that when I write cut # in my Search box then data of that cuts will appear in "A:E". Search box is only an idea it could be a list like filter where I can check multiple cuts at a time. Link of my file is given bellow. This is only sample data rows of this data may increase.

Cut Detail.xlsm

Thanks in advance for help.

Regards,
NAVI_G
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi Navi,

This can be done easily with Advanced Filter ... For the below macro to work, remove merge cells, in cell G2 type "CUT #" & list below it all needed numbers to be used for the filter then run below macro
VBA Code:
Sub test()

[J1].CurrentRegion.Offset(1).AdvancedFilter 2, [G2].CurrentRegion, [A2:E2]

End Sub
 
Upvote 0
Solution
Hi Navi,

This can be done easily with Advanced Filter ... For the below macro to work, remove merge cells, in cell G2 type "CUT #" & list below it all needed numbers to be used for the filter then run below macro
VBA Code:
Sub test()

[J1].CurrentRegion.Offset(1).AdvancedFilter 2, [G2].CurrentRegion, [A2:E2]

End Sub
Dear sir I know how to use filters but I need only a VBA code for this its to tough for my data
 
Upvote 0
I have already provided the VBA code :) ... Give it a try
 
Upvote 0
I have already provided the VBA code :) ... Give it a try
Dear sir I tried this code but is not working properly. When I type "CUT #" in "G2" like "353" it bring whole data of Range "J:N" in range "A:E". Selection is not working.
 
Upvote 0
Hi All,
Pls provide help against this theory.
 
Upvote 0
R2 CUT #
R3 342
R4 345
R5 353

select J2
Data--> Advanced (sort & filter)
List range already selected
Criteria range select $R$2:$R$5
Click on Copy to another location
Copy to $A$2:$E$2
Press --> OK.

If data is changed you have to refresh filter.
 
Upvote 0
Hi Navi,

I have attached a copy of the workbook with the macro suggested in post # 2 & it is working fine with me ... Try the attached workbook & let me know if it doesn't work for you

DropBox File Here
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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