Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copying Down Cells after Unique Filter

Hi, I'm trying to build a spreadsheet, in VBA, based on timesheet data. I'd
like a total of time spent on each task. The task list can change so the
first job is to define all unique tasks. I've used the following:



Sheets("Detail").Columns("E:E").AdvancedFilter Action:=xlFilterCopy, _

CopyToRange:=Range("A1"), Unique:=True



Works fine. The problem comes when I try and automatically copy down the
formulas I want to use on each row against each task description. I started
with this:



Dim lLastRow As Long



lLastRow = Sheets("Monthly
Summary").Cells.SpecialCells(xlCellTypeLastCell).R ow



Debug.Print "lLastRow = " & lLastRow



Worksheets("Monthly Summary").Activate

Range("B2:N2").Select



Selection.AutoFill Destination:=Sheets("Monthly Summary").Range("B2:N" &
lLastRow - 1), Type:=xlFillDefault



The problem I face is that on my destination sheet I can only 'see' thirty
or so tasks but lLastRow reports 440 with nothing 'visible' in cells 31 to
440! Hence, my copy down goes on way beyond where I need it to finish.



Any suggestions please?



Thanks,



Jon C



p.s. I know pivots would be an ideal approach but there are downstream
limitations to using them here.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Copying Down Cells after Unique Filter

It is a little hard to tell exactly what you want but in a nut shell you want
to do stuff with the visible cells? How about using something similar to

Dim rng As Range
Set rng = Sheet1.Range("A1:A100").SpecialCells(xlCellTypeVis ible)

if rng is nothing then
'No visible cells so do nithing....
endif

the range object is no only the visible cells and you can use it to do that
voodoo that you do...

HTH

"Jon C" wrote:

Hi, I'm trying to build a spreadsheet, in VBA, based on timesheet data. I'd
like a total of time spent on each task. The task list can change so the
first job is to define all unique tasks. I've used the following:



Sheets("Detail").Columns("E:E").AdvancedFilter Action:=xlFilterCopy, _

CopyToRange:=Range("A1"), Unique:=True



Works fine. The problem comes when I try and automatically copy down the
formulas I want to use on each row against each task description. I started
with this:



Dim lLastRow As Long



lLastRow = Sheets("Monthly
Summary").Cells.SpecialCells(xlCellTypeLastCell).R ow



Debug.Print "lLastRow = " & lLastRow



Worksheets("Monthly Summary").Activate

Range("B2:N2").Select



Selection.AutoFill Destination:=Sheets("Monthly Summary").Range("B2:N" &
lLastRow - 1), Type:=xlFillDefault



The problem I face is that on my destination sheet I can only 'see' thirty
or so tasks but lLastRow reports 440 with nothing 'visible' in cells 31 to
440! Hence, my copy down goes on way beyond where I need it to finish.



Any suggestions please?



Thanks,



Jon C



p.s. I know pivots would be an ideal approach but there are downstream
limitations to using them here.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying Down Cells after Unique Filter

Try this modification:

With Sheets("Detail")
set rng = .Range(.Cells(1,"E"),.Cells(rows.count,"E").End(xl up))
End With
rng.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Sheets("Monthly Summary") _
.Range("A1"), Unique:=True

if that is still problematic (and it may be, I recall some problem like this
with advanced filter) then try


Dim lLastRow As Long
lLastRow = 1
With Sheets("Monthly Summary")
do while trim( .cells(lLastRow + 1,1).Text) < ""
lLastRow = lLastRow + 1
Loop
End With
Debug.Print "lLastRow = " & lLastRow
Worksheets("Monthly Summary").Activate
Range("B2:N2").Select
Selection.AutoFill Destination:=Sheets( _
"Monthly Summary").Range("B2:N" & _
lLastRow - 1), Type:=xlFillDefault

--
Regards,
Tom Ogilvy



"Jon C" wrote in message
...
Hi, I'm trying to build a spreadsheet, in VBA, based on timesheet data.

I'd
like a total of time spent on each task. The task list can change so the
first job is to define all unique tasks. I've used the following:



Sheets("Detail").Columns("E:E").AdvancedFilter Action:=xlFilterCopy, _

CopyToRange:=Sheets("Monthly Summary").Range("A1"), Unique:=True



Works fine. The problem comes when I try and automatically copy down the
formulas I want to use on each row against each task description. I

started
with this:



Dim lLastRow As Long



lLastRow = Sheets("Monthly
Summary").Cells.SpecialCells(xlCellTypeLastCell).R ow



Debug.Print "lLastRow = " & lLastRow



Worksheets("Monthly Summary").Activate

Range("B2:N2").Select



Selection.AutoFill Destination:=Sheets("Monthly Summary").Range("B2:N"

&
lLastRow - 1), Type:=xlFillDefault



The problem I face is that on my destination sheet I can only 'see' thirty
or so tasks but lLastRow reports 440 with nothing 'visible' in cells 31 to
440! Hence, my copy down goes on way beyond where I need it to finish.



Any suggestions please?



Thanks,



Jon C



p.s. I know pivots would be an ideal approach but there are downstream
limitations to using them here.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copying Down Cells after Unique Filter

Great, got it going.

Thanks Jim and Tom...

"Jon C" wrote in message
...
Hi, I'm trying to build a spreadsheet, in VBA, based on timesheet data.
I'd like a total of time spent on each task. The task list can change so
the first job is to define all unique tasks. I've used the following:



Sheets("Detail").Columns("E:E").AdvancedFilter Action:=xlFilterCopy, _

CopyToRange:=Range("A1"), Unique:=True



Works fine. The problem comes when I try and automatically copy down the
formulas I want to use on each row against each task description. I
started with this:



Dim lLastRow As Long



lLastRow = Sheets("Monthly
Summary").Cells.SpecialCells(xlCellTypeLastCell).R ow



Debug.Print "lLastRow = " & lLastRow



Worksheets("Monthly Summary").Activate

Range("B2:N2").Select



Selection.AutoFill Destination:=Sheets("Monthly Summary").Range("B2:N"
& lLastRow - 1), Type:=xlFillDefault



The problem I face is that on my destination sheet I can only 'see' thirty
or so tasks but lLastRow reports 440 with nothing 'visible' in cells 31 to
440! Hence, my copy down goes on way beyond where I need it to finish.



Any suggestions please?



Thanks,



Jon C



p.s. I know pivots would be an ideal approach but there are downstream
limitations to using them here.




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
Copying Filter Data & Using for each in cells Vick Excel Discussion (Misc queries) 0 November 20th 07 09:49 PM
copying only cells in a filter with data mattguerilla Excel Discussion (Misc queries) 0 December 5th 06 03:43 PM
unique filter results in some non-unique records. Serials Librarian Excel Discussion (Misc queries) 2 May 26th 06 09:58 PM
Unique Value without using FILTER Amit Dhawan Excel Worksheet Functions 3 October 11th 05 03:21 PM
Formulas for...1. Counting unique cells 2. Display unique contents J Excel Programming 0 April 23rd 04 09:20 PM


All times are GMT +1. The time now is 02:52 AM.

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"