Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default data filter via VBA

I have a command button that runs code in order to assign a random number and save a workbook. I would like to add a step to this code so that it takes the number that is in WorkSheet Start cell D1, and uses that number in a data filter that is on another worksheet. The location of the filter is: APsheet cell E3, and I would like that to filter for anything that contains the number from Start D1.
Is this possible, or should I find another method?

Thanks in advance!
Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default data filter via VBA

Hi Paul,

Am Sun, 10 Jul 2016 15:58:24 -0700 (PDT) schrieb Paul Doucette:

I have a command button that runs code in order to assign a random number and save a workbook. I would like to add a step to this code so that it takes the number that is in WorkSheet ?Start? cell D1, and uses that number in a data filter that is on another worksheet. The location of the filter is: APsheet cell E3, and I would like that to filter for anything that ?contains? the number from Start D1.
Is this possible, or should I find another method?


are the values in column E text? Then you can try:

Sub Filter()
Dim crit As String
Dim myRng As Range
Dim LRow As Long

crit = Sheets("Start").Range("D1")
With Sheets("APsheet")
LRow = .Cells(Rows.Count, "E").End(xlUp).Row
.Range("E3:E" & LRow).AutoFilter Field:=5, Criteria1:="=*" & crit & "*"
End With
End Sub

If the values in E are numbers they will be handled as numbers even if
you format them as text and "contains" is not possible.



Regards
Claus B.
--
Windows10
Office 2016
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default data filter via VBA

On Sunday, July 10, 2016 at 6:58:29 PM UTC-4, Paul Doucette wrote:
I have a command button that runs code in order to assign a random number and save a workbook. I would like to add a step to this code so that it takes the number that is in WorkSheet Start cell D1, and uses that number in a data filter that is on another worksheet. The location of the filter is: APsheet cell E3, and I would like that to filter for anything that contains the number from Start D1.
Is this possible, or should I find another method?

Thanks in advance!
Paul


The values are text, and it works perfectly. I have been abusing your kindness, Claus! Thank you!!!! I hope you have a pleasant day (or evening... not sire of the time difference)
Paul
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter, Cell Reference formula and copy formula on filter data umpire_43 Excel Programming 0 July 9th 09 03:38 PM
DataFilterAuto Filter in excel 2007? TIJ New Users to Excel 2 November 13th 08 04:28 AM
Data - Filter - Auto Filter neostar77 Excel Discussion (Misc queries) 1 October 27th 08 04:20 AM
in data/filter/auto filter sp8 Excel Worksheet Functions 2 May 12th 06 01:03 AM
"Criteria Range" in the "Data/Filter/Advanced Filter" to select Du TC Excel Worksheet Functions 1 May 12th 05 02:06 AM


All times are GMT +1. The time now is 03:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"