ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofilter based on user inputbox (https://www.excelbanter.com/excel-programming/444567-re-autofilter-based-user-inputbox.html)

Steve[_4_]

Autofilter based on user inputbox
 
Hey Garry,

Within this snippet of code:

With wksTarget
.Rows("1:" & CStr(.UsedRange.Rows.Count)).ClearContents
.Rows("1:" & CStr(.UsedRange.Rows.Count)).ClearComments
.Rows("1:" & CStr(.UsedRange.Rows.Count)).Interior.ColorIndex = xlNone
End With

With wksSource
columnfilter.EntireColumn.AutoFilter Field:=1, Criteria1:="Y"
.UsedRange.Copy
wksTarget.Range("1:1").PasteSpecial Paste:=xlPasteColumnWidths
.UsedRange.Copy wksTarget.Range("1:1") '//put the data
.Columns("K:K").AutoFilter
End With

When I copy rows based on the autofilter, it appears that by using "usedrange" I am ommitting hidden columns. IS there a way to include hidden columns in the copy/paste as well? Thanks!

GS[_2_]

Autofilter based on user inputbox
 
Try...


With wksSource
.Activate
.RngToFilter.EntireColumn.AutoFilter Field:=1, Criteria1:="Y"
.UsedRange.Select: Selection.Copy
With wksTarget.Range("1:1")
.PasteSpecial Paste:=xlPasteColumnWidths
.PasteSpecial Paste:=xlPasteValues
End With
.RngToFilter.EntireColumn.AutoFilter
End With

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com