Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Autofilter tables Uniquelist

I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.

Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)

I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.

Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously

Can this be done?
Any help is appreciated. I have been stuck in this for while now.

Thanks
vishnu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Autofilter tables Uniquelist

You can't post files on this website


Sheets("Sheet1").Columns("B:B").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
Unique:=True
with Sheets("Sheet2")
LastRow = .Range("C1").end(xldown).row
set ListName = .Range("C1:C" & Lastrow)
end with


" wrote:

I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.

Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)

I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.

Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously

Can this be done?
Any help is appreciated. I have been stuck in this for while now.

Thanks
vishnu

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Autofilter tables Uniquelist


Thanks Joel,

It works fine.

Kindly excuse for the attachment, was not aware.

Could you also guide me with the following

For each value from the unique list I filter two tables in two
different sheets and would like to multiply corresponding column
values

I had used a similar code to find corresponding column values and was
trying to modify the same, the following is

Dim rFoundIt As Range
Dim iLoop As Integer

Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")

Worksheets("temp1").Activate
Selection.AutoFilter Field:=3, Criteria1:=model

Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model


'Select corresponding column value for each model


With Sheets("rawdata").Range("data")

Set rFoundIt = .Cells(1, 1)

For iLoop = 1 To WorksheetFunction.CountIf _
(Sheets("temp1").Range("output"),
model)

Set rFoundIt = .Find(What:=model, After:=rFoundIt, _
LookIn:=xlValues, LookAt:=xlWhole,
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

Next iLoop
''' The above loop selects appropriate data from the "rawdata" sheet.
How do I select columns from "temp1" sheet. to multiply values.

Is this the correct way of doing this? Is there any other way.

Thanks
vishnu


On Mar 24, 3:53*pm, Joel wrote:
You can't post files on this website

Sheets("Sheet1").Columns("B:B").AdvancedFilter _
* * Action:=xlFilterCopy, _
* * CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
* * Unique:=True
with Sheets("Sheet2")
* *LastRow = .Range("C1").end(xldown).row
* *set ListName = .Range("C1:C" & Lastrow)
end with



" wrote:
I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.


Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)


I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.


Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously


Can this be done?
Any help is appreciated. I have been stuck in this for while now.


Thanks
vishnu- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Autofilter tables Uniquelist

Is this code better?

Sub test2()



Dim rFoundIt As Range
Dim iLoop As Integer

Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")

Worksheets("temp1").Activate
'selection is not defined, you should use a real range
' I think you should replace selection with model
Selection.AutoFilter Field:=3, Criteria1:=model
'use special cells
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy
' or
Set temp1range =
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible)

Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model
'use special cells
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible).Copy
' or
Set rawdatarange =
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible)

'you can copy the two ranges to a new worksheet
With Sheets("New")
temp1range.Copy Destination:=.Range("A1")
rawdatarange.Copy Destination:=.Range("B1")

RowCount = 1
Do While .Range("A" & RowCount) < ""
Answer = .Range("A" & RowCount) * .Range("B" & RowCount)

RowCount = RowCount + 1
Loop
End With


Next model



End Sub

" wrote:


Thanks Joel,

It works fine.

Kindly excuse for the attachment, was not aware.

Could you also guide me with the following

For each value from the unique list I filter two tables in two
different sheets and would like to multiply corresponding column
values

I had used a similar code to find corresponding column values and was
trying to modify the same, the following is

Dim rFoundIt As Range
Dim iLoop As Integer

Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")

Worksheets("temp1").Activate
Selection.AutoFilter Field:=3, Criteria1:=model

Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model


'Select corresponding column value for each model


With Sheets("rawdata").Range("data")

Set rFoundIt = .Cells(1, 1)

For iLoop = 1 To WorksheetFunction.CountIf _
(Sheets("temp1").Range("output"),
model)

Set rFoundIt = .Find(What:=model, After:=rFoundIt, _
LookIn:=xlValues, LookAt:=xlWhole,
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

Next iLoop
''' The above loop selects appropriate data from the "rawdata" sheet.
How do I select columns from "temp1" sheet. to multiply values.

Is this the correct way of doing this? Is there any other way.

Thanks
vishnu


On Mar 24, 3:53 pm, Joel wrote:
You can't post files on this website

Sheets("Sheet1").Columns("B:B").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
Unique:=True
with Sheets("Sheet2")
LastRow = .Range("C1").end(xldown).row
set ListName = .Range("C1:C" & Lastrow)
end with



" wrote:
I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.


Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)


I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.


Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously


Can this be done?
Any help is appreciated. I have been stuck in this for while now.


Thanks
vishnu- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Autofilter tables Uniquelist


Hi Joel,

Thanks for the code.

It works in parts, possibly because I did not explain myself clearly.

When I run your code I get an error "Run time error 9 out of range".

Secondly your code is selecting the entire criteria column, when I
filter the list I would like to select the entire visible row and put
it into a sheet.

I think I can do this by Offset(0,
ActiveCell.CurrentRegion.Columns.Count + 1) and copy the entire row.

Did I miss something?

Thanks
Vishnu


On Mar 24, 8:28*pm, Joel wrote:
Is this code better?

Sub test2()

Dim rFoundIt As Range
Dim iLoop As Integer

Dim model As Range

For Each model In Worksheets("temp1").Range("filterlist")

Worksheets("temp1").Activate
'selection is not defined, you should use a real range
' I think you should replace selection with model
Selection.AutoFilter Field:=3, Criteria1:=model
'use special cells
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy
' or
Set temp1range =
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible)

Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model
'use special cells
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible).Copy
' or
Set rawdatarange =
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible)

'you can copy the two ranges to a new worksheet
With Sheets("New")
* *temp1range.Copy Destination:=.Range("A1")
* *rawdatarange.Copy Destination:=.Range("B1")

* *RowCount = 1
* *Do While .Range("A" & RowCount) < ""
* * * Answer = .Range("A" & RowCount) * .Range("B" & RowCount)

* * * RowCount = RowCount + 1
* *Loop
End With

Next model

End Sub



" wrote:

Thanks Joel,


It works fine.


Kindly excuse for the attachment, was not aware.


Could you also guide me with the following


For each value from the unique list I filter two tables in two
different sheets and would like to multiply corresponding column
values


I had used a similar code to find corresponding column values and was
trying to modify the same, the following is


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
Selection.AutoFilter Field:=3, Criteria1:=model


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model


'Select corresponding column value for each model


* * With Sheets("rawdata").Range("data")


* * * * *Set rFoundIt = .Cells(1, 1)


* * * * * * *For iLoop = 1 To WorksheetFunction.CountIf _
* * * * * * * * * * * * * * * * (Sheets("temp1").Range("output"),
model)


* * * * * * * * Set rFoundIt = .Find(What:=model, After:=rFoundIt, _
* * * * * * * * LookIn:=xlValues, LookAt:=xlWhole,
SearchOrder:=xlByRows, _
* * * * * * * * SearchDirection:=xlNext, MatchCase:=False)


* * * * * * * Next iLoop
*''' The above loop selects appropriate data from the "rawdata" sheet.
How do I select columns from "temp1" sheet. to multiply values.


Is this the correct way of doing this? Is there any other way.


Thanks
vishnu


On Mar 24, 3:53 pm, Joel wrote:
You can't post files on this website


Sheets("Sheet1").Columns("B:B").AdvancedFilter _
* * Action:=xlFilterCopy, _
* * CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
* * Unique:=True
with Sheets("Sheet2")
* *LastRow = .Range("C1").end(xldown).row
* *set ListName = .Range("C1:C" & Lastrow)
end with


" wrote:
I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.


Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)


I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.


Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously


Can this be done?
Any help is appreciated. I have been stuck in this for while now.


Thanks
vishnu- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Autofilter tables Uniquelist

Only the visible cells get copied with the following statment

Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy

to change this so the entire row gets copied is simple

Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).entirerow.Copy

You are probably getting a run time error because of the number of filter
columns on your worksheet.

using AutofilterField:=5 referes to the 5th filter column in the worksheet,
not column E (the fifth column). I can't tell by the code which columns on
your worksheet are filtered. You may need to adjust the columns I selected
to get the code to work with your data.

" wrote:


Hi Joel,

Thanks for the code.

It works in parts, possibly because I did not explain myself clearly.

When I run your code I get an error "Run time error 9 out of range".

Secondly your code is selecting the entire criteria column, when I
filter the list I would like to select the entire visible row and put
it into a sheet.

I think I can do this by Offset(0,
ActiveCell.CurrentRegion.Columns.Count + 1) and copy the entire row.

Did I miss something?

Thanks
Vishnu


On Mar 24, 8:28 pm, Joel wrote:
Is this code better?

Sub test2()

Dim rFoundIt As Range
Dim iLoop As Integer

Dim model As Range

For Each model In Worksheets("temp1").Range("filterlist")

Worksheets("temp1").Activate
'selection is not defined, you should use a real range
' I think you should replace selection with model
Selection.AutoFilter Field:=3, Criteria1:=model
'use special cells
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy
' or
Set temp1range =
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible)

Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model
'use special cells
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible).Copy
' or
Set rawdatarange =
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible)

'you can copy the two ranges to a new worksheet
With Sheets("New")
temp1range.Copy Destination:=.Range("A1")
rawdatarange.Copy Destination:=.Range("B1")

RowCount = 1
Do While .Range("A" & RowCount) < ""
Answer = .Range("A" & RowCount) * .Range("B" & RowCount)

RowCount = RowCount + 1
Loop
End With

Next model

End Sub



" wrote:

Thanks Joel,


It works fine.


Kindly excuse for the attachment, was not aware.


Could you also guide me with the following


For each value from the unique list I filter two tables in two
different sheets and would like to multiply corresponding column
values


I had used a similar code to find corresponding column values and was
trying to modify the same, the following is


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
Selection.AutoFilter Field:=3, Criteria1:=model


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model


'Select corresponding column value for each model


With Sheets("rawdata").Range("data")


Set rFoundIt = .Cells(1, 1)


For iLoop = 1 To WorksheetFunction.CountIf _
(Sheets("temp1").Range("output"),
model)


Set rFoundIt = .Find(What:=model, After:=rFoundIt, _
LookIn:=xlValues, LookAt:=xlWhole,
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)


Next iLoop
''' The above loop selects appropriate data from the "rawdata" sheet.
How do I select columns from "temp1" sheet. to multiply values.


Is this the correct way of doing this? Is there any other way.


Thanks
vishnu


On Mar 24, 3:53 pm, Joel wrote:
You can't post files on this website


Sheets("Sheet1").Columns("B:B").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
Unique:=True
with Sheets("Sheet2")
LastRow = .Range("C1").end(xldown).row
set ListName = .Range("C1:C" & Lastrow)
end with


" wrote:
I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.


Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)


I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.


Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously


Can this be done?
Any help is appreciated. I have been stuck in this for while now.


Thanks
vishnu- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Autofilter tables Uniquelist

Joel,

Thanks I got it.

I am now stuck on how to multiply column.

Sheet temp1:

Headers (A1:Q1)
country group model segment 2007penetration supplier 2005 2006 2008
2009 2010 2011 2012 2013 2014 2015

Sheet rawdata:
Headers (A1: S1)
region country group MM model type segment GS 2005 2006 2007 2008
2009 2010 2011 2012 2013 2014 2015

When I filter both the sheets using "filterlist" from "sheet2"

I need to change the following columns in table in sheet "temp1"
columns 2005 to 2015 should contain the product of the respective
columns

ex
"Temp1" after Modification should look like the following

2005 column should be = "original2005 column temp1" *
"rawdata2005 column value"
)

Would you be able to guide me?

Thanks
Vishnu



On Mar 25, 3:28*pm, Joel wrote:
Only the visible cells get copied with the following statment

Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy

to change this so the entire row gets copied is simple

Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).entirero*w.Copy

You are probably getting a run time error because of the number of filter
columns on your worksheet.

using AutofilterField:=5 referes to the 5th filter column in the worksheet,
not column E (the fifth column). *I can't tell by the code which columns on
your worksheet are filtered. *You may need to adjust the columns I selected
to get the code to work with your data.



" wrote:

Hi Joel,


Thanks for the code.


It works in parts, possibly because I did not explain myself clearly.


When I run your code I get an error "Run time error 9 out of range".


Secondly your code is selecting the entire criteria column, when I
filter the list I would like to select the entire visible row and put
it into a sheet.


I think I can do this by Offset(0,
ActiveCell.CurrentRegion.Columns.Count + 1) and copy the entire row.


Did I miss something?


Thanks
Vishnu


On Mar 24, 8:28 pm, Joel wrote:
Is this code better?


Sub test2()


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
'selection is not defined, you should use a real range
' I think you should replace selection with model
Selection.AutoFilter Field:=3, Criteria1:=model
'use special cells
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy
' or
Set temp1range =
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible)


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model
'use special cells
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible).Copy
' or
Set rawdatarange =
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible)


'you can copy the two ranges to a new worksheet
With Sheets("New")
* *temp1range.Copy Destination:=.Range("A1")
* *rawdatarange.Copy Destination:=.Range("B1")


* *RowCount = 1
* *Do While .Range("A" & RowCount) < ""
* * * Answer = .Range("A" & RowCount) * .Range("B" & RowCount)


* * * RowCount = RowCount + 1
* *Loop
End With


Next model


End Sub


" wrote:


Thanks Joel,


It works fine.


Kindly excuse for the attachment, was not aware.


Could you also guide me with the following


For each value from the unique list I filter two tables in two
different sheets and would like to multiply corresponding column
values


I had used a similar code to find corresponding column values and was
trying to modify the same, the following is


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
Selection.AutoFilter Field:=3, Criteria1:=model


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model


'Select corresponding column value for each model


* * With Sheets("rawdata").Range("data")


* * * * *Set rFoundIt = .Cells(1, 1)


* * * * * * *For iLoop = 1 To WorksheetFunction.CountIf _
* * * * * * * * * * * * * * * * (Sheets("temp1").Range("output"),
model)


* * * * * * * * Set rFoundIt = .Find(What:=model, After:=rFoundIt, _
* * * * * * * * LookIn:=xlValues, LookAt:=xlWhole,
SearchOrder:=xlByRows, _
* * * * * * * * SearchDirection:=xlNext, MatchCase:=False)


* * * * * * * Next iLoop
*''' The above loop selects appropriate data from the "rawdata" sheet.
How do I select columns from "temp1" sheet. to multiply values.


Is this the correct way of doing this? Is there any other way.


Thanks
vishnu


On Mar 24, 3:53 pm, Joel wrote:
You can't post files on this website


Sheets("Sheet1").Columns("B:B").AdvancedFilter _
* * Action:=xlFilterCopy, _
* * CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
* * Unique:=True
with Sheets("Sheet2")
* *LastRow = .Range("C1").end(xldown).row
* *set ListName = .Range("C1:C" & Lastrow)
end with


" wrote:
I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.


Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)


I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.


Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously


Can this be done?
Any help is appreciated. I have been stuck in this for while now..


Thanks
vishnu- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Autofilter tables Uniquelist

I assum the columns on both sheets are in the same order (you skipped 2007 on
temp1)

with sheets("rawdata")
LastRow = .range("A" & Rows.count).end(xlup).row
for ColCount = 1 to Range("S1").Column
for RowCount = 2 to LastRow
.Cells(RowCount,Colcount) =
sheets("temp1").Cells(RowCount,Colcount) * _
.Cells(RowCount,Colcount)
next RowCount
next ColCount
end with
" wrote:

Joel,

Thanks I got it.

I am now stuck on how to multiply column.

Sheet temp1:

Headers (A1:Q1)
country group model segment 2007penetration supplier 2005 2006 2008
2009 2010 2011 2012 2013 2014 2015

Sheet rawdata:
Headers (A1: S1)
region country group MM model type segment GS 2005 2006 2007 2008
2009 2010 2011 2012 2013 2014 2015

When I filter both the sheets using "filterlist" from "sheet2"

I need to change the following columns in table in sheet "temp1"
columns 2005 to 2015 should contain the product of the respective
columns

ex
"Temp1" after Modification should look like the following

2005 column should be = "original2005 column temp1" *
"rawdata2005 column value"
)

Would you be able to guide me?

Thanks
Vishnu



On Mar 25, 3:28 pm, Joel wrote:
Only the visible cells get copied with the following statment

Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy

to change this so the entire row gets copied is simple

Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).entireroÂ*w.Copy

You are probably getting a run time error because of the number of filter
columns on your worksheet.

using AutofilterField:=5 referes to the 5th filter column in the worksheet,
not column E (the fifth column). I can't tell by the code which columns on
your worksheet are filtered. You may need to adjust the columns I selected
to get the code to work with your data.



" wrote:

Hi Joel,


Thanks for the code.


It works in parts, possibly because I did not explain myself clearly.


When I run your code I get an error "Run time error 9 out of range".


Secondly your code is selecting the entire criteria column, when I
filter the list I would like to select the entire visible row and put
it into a sheet.


I think I can do this by Offset(0,
ActiveCell.CurrentRegion.Columns.Count + 1) and copy the entire row.


Did I miss something?


Thanks
Vishnu


On Mar 24, 8:28 pm, Joel wrote:
Is this code better?


Sub test2()


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
'selection is not defined, you should use a real range
' I think you should replace selection with model
Selection.AutoFilter Field:=3, Criteria1:=model
'use special cells
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy
' or
Set temp1range =
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible)


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model
'use special cells
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible).Copy
' or
Set rawdatarange =
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible)


'you can copy the two ranges to a new worksheet
With Sheets("New")
temp1range.Copy Destination:=.Range("A1")
rawdatarange.Copy Destination:=.Range("B1")


RowCount = 1
Do While .Range("A" & RowCount) < ""
Answer = .Range("A" & RowCount) * .Range("B" & RowCount)


RowCount = RowCount + 1
Loop
End With


Next model


End Sub


" wrote:


Thanks Joel,


It works fine.


Kindly excuse for the attachment, was not aware.


Could you also guide me with the following


For each value from the unique list I filter two tables in two
different sheets and would like to multiply corresponding column
values


I had used a similar code to find corresponding column values and was
trying to modify the same, the following is


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
Selection.AutoFilter Field:=3, Criteria1:=model


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model


'Select corresponding column value for each model


With Sheets("rawdata").Range("data")


Set rFoundIt = .Cells(1, 1)


For iLoop = 1 To WorksheetFunction.CountIf _
(Sheets("temp1").Range("output"),
model)


Set rFoundIt = .Find(What:=model, After:=rFoundIt, _
LookIn:=xlValues, LookAt:=xlWhole,
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)


Next iLoop
''' The above loop selects appropriate data from the "rawdata" sheet.
How do I select columns from "temp1" sheet. to multiply values.


Is this the correct way of doing this? Is there any other way.


Thanks
vishnu


On Mar 24, 3:53 pm, Joel wrote:
You can't post files on this website


Sheets("Sheet1").Columns("B:B").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
Unique:=True
with Sheets("Sheet2")
LastRow = .Range("C1").end(xldown).row
set ListName = .Range("C1:C" & Lastrow)
end with


" wrote:
I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.


Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)


I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL. and then
name that list separately.


Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously


Can this be done?
Any help is appreciated. I have been stuck in this for while now..


Thanks
vishnu- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Autofilter tables Uniquelist

Thanks Joel for your time. Your code works. I was able to modify it
with rows




On Mar 25, 7:59*pm, Joel wrote:
I assum the columns on both sheets are in the same order (you skipped 2007 on
temp1)

with sheets("rawdata")
* *LastRow = .range("A" & Rows.count).end(xlup).row
* *for ColCount = 1 to Range("S1").Column
* * * for RowCount = 2 to LastRow
* * * * *.Cells(RowCount,Colcount) =
sheets("temp1").Cells(RowCount,Colcount) * _
* * * * *.Cells(RowCount,Colcount)
* * * next RowCount
* *next ColCount
end with



" wrote:
Joel,


Thanks I got it.


I am now stuck on how to multiply column.


Sheet temp1:


Headers (A1:Q1)
country group model segment 2007penetration supplier 2005 2006 2008
2009 2010 2011 2012 2013 2014 2015


Sheet rawdata:
Headers (A1: S1)
region country group MM model type segment GS *2005 2006 2007 2008
2009 2010 2011 2012 2013 2014 2015


When I filter both the sheets using "filterlist" from "sheet2"


I need to change the following columns in table in sheet "temp1"
columns 2005 to 2015 should contain the product of the respective
columns


ex
"Temp1" after Modification should look like the following


2005 column should be = "original2005 column temp1" * *
"rawdata2005 column value"
)


Would you be able to guide me?


Thanks
Vishnu


On Mar 25, 3:28 pm, Joel wrote:
Only the visible cells get copied with the following statment


Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).Copy


to change this so the entire row gets copied is simple


Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible).entirero**w.Copy


You are probably getting a run time error because of the number of filter
columns on your worksheet.


using AutofilterField:=5 referes to the 5th filter column in the worksheet,
not column E (the fifth column). *I can't tell by the code which columns on
your worksheet are filtered. *You may need to adjust the columns I selected
to get the code to work with your data.


" wrote:


Hi Joel,


Thanks for the code.


It works in parts, possibly because I did not explain myself clearly..


When I run your code I get an error "Run time error 9 out of range".


Secondly your code is selecting the entire criteria column, when I
filter the list I would like to select the entire visible row and put
it into a sheet.


I think I can do this by Offset(0,
ActiveCell.CurrentRegion.Columns.Count + 1) and copy the entire row.


Did I miss something?


Thanks
Vishnu


On Mar 24, 8:28 pm, Joel wrote:
Is this code better?


Sub test2()


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
'selection is not defined, you should use a real range
' I think you should replace selection with model
Selection.AutoFilter Field:=3, Criteria1:=model
'use special cells
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible)..Copy
' or
Set temp1range =
Worksheets("temp1").Columns("C:C").SpecialCells(xl CellTypeVisible)


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model
'use special cells
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible).Copy
' or
Set rawdatarange =
Worksheets("rawdata").Columns("E:E").SpecialCells( xlCellTypeVisible)


'you can copy the two ranges to a new worksheet
With Sheets("New")
* *temp1range.Copy Destination:=.Range("A1")
* *rawdatarange.Copy Destination:=.Range("B1")


* *RowCount = 1
* *Do While .Range("A" & RowCount) < ""
* * * Answer = .Range("A" & RowCount) * .Range("B" & RowCount)


* * * RowCount = RowCount + 1
* *Loop
End With


Next model


End Sub


" wrote:


Thanks Joel,


It works fine.


Kindly excuse for the attachment, was not aware.


Could you also guide me with the following


For each value from the unique list I filter two tables in two
different sheets and would like to multiply corresponding column
values


I had used a similar code to find corresponding column values and was
trying to modify the same, the following is


Dim rFoundIt As Range
Dim iLoop As Integer


Dim model As Range


For Each model In Worksheets("temp1").Range("filterlist")


Worksheets("temp1").Activate
Selection.AutoFilter Field:=3, Criteria1:=model


Worksheets("rawdata").Activate
Selection.AutoFilter Field:=5, Criteria1:=model


'Select corresponding column value for each model


* * With Sheets("rawdata").Range("data")


* * * * *Set rFoundIt = .Cells(1, 1)


* * * * * * *For iLoop = 1 To WorksheetFunction.CountIf _
* * * * * * * * * * * * * * * * (Sheets("temp1").Range("output"),
model)


* * * * * * * * Set rFoundIt = .Find(What:=model, After:=rFoundIt, _
* * * * * * * * LookIn:=xlValues, LookAt:=xlWhole,
SearchOrder:=xlByRows, _
* * * * * * * * SearchDirection:=xlNext, MatchCase:=False)


* * * * * * * Next iLoop
*''' The above loop selects appropriate data from the "rawdata" sheet.
How do I select columns from "temp1" sheet. to multiply values.


Is this the correct way of doing this? Is there any other way.


Thanks
vishnu


On Mar 24, 3:53 pm, Joel wrote:
You can't post files on this website


Sheets("Sheet1").Columns("B:B").AdvancedFilter _
* * Action:=xlFilterCopy, _
* * CopyToRange:=Sheets("Sheet2").Columns("C:C"), _
* * Unique:=True
with Sheets("Sheet2")
* *LastRow = .Range("C1").end(xldown).row
* *set ListName = .Range("C1:C" & Lastrow)
end with


" wrote:
I have a table and say I would like to create a unique list from
column2 and store the list in a spearate sheet. Give this unique list
a name.


Use this unique list in a FOR EACH loop and apply autofilter to two
tables on two different sheets.
(one table is from which the unique list was created and other in a
different sheet)


I have attached a file wiith the table headers. In sheet2 there is a
table and i need to produce an unique list from column MODEL.. and then
name that list separately.


Using this unique list I would like to autofilter the same table on
sheet2 and table on sheet3
simultaneously


Can this be done?
Any help is appreciated. I have been stuck in this for while now..


Thanks
vishnu- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


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
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
Creating tables using AutoFilter in Macro [email protected] Excel Programming 1 February 9th 07 07:05 PM


All times are GMT +1. The time now is 04:52 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"