View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Understanding Issues with INTERSECT function in VBA

Hi again,

Am Tue, 17 Feb 2015 16:48:44 +0100 schrieb Claus Busch:

to find the values and select the range try (modify the ranges for your
table):


if the Group occurs more than once try this:

Sub Test()
Dim LRow As Long
Dim tbl As Range
Dim myCol As Long, myRow As Long, CountR As Long

With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
Set tbl = .Range("A1:M" & LRow)
tbl.Sort key1:=.Range("A1"), order1:=xlAscending, Header:=xlYes
myCol = WorksheetFunction.Match(Month(.Cells(1, 20)), .Range("A1:M1"), 0)
myRow = WorksheetFunction.Match(.Cells(1, 21), .Range("A1:A" & LRow), 0)
CountR = WorksheetFunction.CountIf(.Range("A:A"), .Cells(1, 21))
Application.Goto Union(.Rows(myRow).Resize(CountR), .Columns(myCol))
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional