Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ksp ksp is offline
external usenet poster
 
Posts: 1
Default Advanced Filtering


Hi All

I have a list of data that has been "dumped" from another system int
Excel, that fills Columns A thru N. I need to extract from this al
rows that have the number 1 in column G, however I cannot seem to b
able to correctly define my criteria for this to work as I keep gettin
a Reference is not valid error

Is what I am trying to do even possible ?

Thanks in advance

Kare

--
ks
-----------------------------------------------------------------------
ksp's Profile: http://www.excelforum.com/member.php...nfo&userid=626
View this thread: http://www.excelforum.com/showthread.php?threadid=48808

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Advanced Filtering

give this a try. it assumes your data is on sheet1 and you want it extracted
to sheet2

Option Explicit
Sub Extract()
Dim rng As Range
Dim cell As Range
Dim lastrow As Long
Dim firstrow As Long
firstrow = 2
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
With Worksheets("sheet1")
Set rng = Range("g1:g" & lastrow)
For Each cell In rng
If cell.Value = 1 Then
.Range("A" & cell).EntireRow.Copy
Worksheets("sheet2").Range("A" & firstrow).PasteSpecial xlValues
firstrow = firstrow + 1
End If
Debug.Print cell.Row
Next cell
End With
Application.CutCopyMode = False
End Sub

--


Gary


"ksp" wrote in message
...

Hi All

I have a list of data that has been "dumped" from another system into
Excel, that fills Columns A thru N. I need to extract from this all
rows that have the number 1 in column G, however I cannot seem to be
able to correctly define my criteria for this to work as I keep getting
a Reference is not valid error

Is what I am trying to do even possible ?

Thanks in advance

Karen


--
ksp
------------------------------------------------------------------------
ksp's Profile:
http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=488087



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Advanced Filtering

sorry, had a typo on this line, for the . row after cell.

..Range("A" & cell.Row).EntireRow.Copy

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
give this a try. it assumes your data is on sheet1 and you want it
extracted to sheet2

Option Explicit
Sub Extract()
Dim rng As Range
Dim cell As Range
Dim lastrow As Long
Dim firstrow As Long
firstrow = 2
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
With Worksheets("sheet1")
Set rng = Range("g1:g" & lastrow)
For Each cell In rng
If cell.Value = 1 Then
.Range("A" & cell).EntireRow.Copy
Worksheets("sheet2").Range("A" & firstrow).PasteSpecial xlValues
firstrow = firstrow + 1
End If
Debug.Print cell.Row
Next cell
End With
Application.CutCopyMode = False
End Sub

--


Gary


"ksp" wrote in message
...

Hi All

I have a list of data that has been "dumped" from another system into
Excel, that fills Columns A thru N. I need to extract from this all
rows that have the number 1 in column G, however I cannot seem to be
able to correctly define my criteria for this to work as I keep getting
a Reference is not valid error

Is what I am trying to do even possible ?

Thanks in advance

Karen


--
ksp
------------------------------------------------------------------------
ksp's Profile:
http://www.excelforum.com/member.php...fo&userid=6267
View this thread:
http://www.excelforum.com/showthread...hreadid=488087





  #4   Report Post  
Posted to microsoft.public.excel.programming
ksp ksp is offline
external usenet poster
 
Posts: 1
Default Advanced Filtering


Hi Gary

Thanks for your script, it sort of works, it certainly recognises that
there are 8 rows that meet this criteria in my test data, but it is
copying Row 1 eight times to sheet 2 instead of the row that the 1
resides in

Are you able to help ?

Thanks

Regards

Karen


--
ksp
------------------------------------------------------------------------
ksp's Profile: http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=488087

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Advanced Filtering

did you try the change i made in the 2nd post?

--


Gary


"ksp" wrote in message
...

Hi Gary

Thanks for your script, it sort of works, it certainly recognises that
there are 8 rows that meet this criteria in my test data, but it is
copying Row 1 eight times to sheet 2 instead of the row that the 1
resides in

Are you able to help ?

Thanks

Regards

Karen


--
ksp
------------------------------------------------------------------------
ksp's Profile:
http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=488087





  #6   Report Post  
Posted to microsoft.public.excel.programming
ksp ksp is offline
external usenet poster
 
Posts: 1
Default Advanced Filtering


Hi Gary

Thanks, that works perfectly now

Thanks for your help - much appreciated

Ta

Karen


--
ksp
------------------------------------------------------------------------
ksp's Profile: http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=488087

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Advanced Filtering

you're welcome

--


Gary


"ksp" wrote in message
...

Hi Gary

Thanks, that works perfectly now

Thanks for your help - much appreciated

Ta

Karen


--
ksp
------------------------------------------------------------------------
ksp's Profile:
http://www.excelforum.com/member.php...fo&userid=6267
View this thread: http://www.excelforum.com/showthread...hreadid=488087



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
how do i use advanced filtering? erik Excel Worksheet Functions 2 October 18th 08 07:14 PM
advanced filtering Lola Excel Discussion (Misc queries) 1 February 27th 08 08:16 PM
advanced filtering jiwolf Excel Worksheet Functions 2 October 19th 05 09:43 PM
advanced filtering in XLS Tina Excel Worksheet Functions 1 September 3rd 05 01:50 PM
Advanced Filtering Tony Excel Worksheet Functions 3 April 29th 05 11:48 AM


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

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

About Us

"It's about Microsoft Excel"