![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Posts: 251
|
Hi,
I am trying to filter column S with Non-Blank cells. If its non blank then I want to select the range, like from column A through U. Range("S16:T16").Select Selection.AutoFilter Selection.AutoFilter Field:=1,_ Criteria1:="<>" Range("A17:U148").Select Selection.Copy I try to put this above codes in macro, it works ok. it gives me probelm when I don't have any non blank cells. becasue after filter,I am selecting the range from A17 - U148 in my codes. Is there any way that after filter if there are any rows after cell A17 then select and copy other wise don't select any range. Can you please help me out here, please. Thanks in advance. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Oregon
Posts: 77
|
Not one hundred percent sure what you are asking but try this.
Sub whatever() On error goto 1 Range("S16:T16").Select Selection.AutoFilter Selection.AutoFilter Field:=1,_ Criteria1:="<>" Range("A17:U148").Select Selection.Copy Exit sub 1: Msgbox "There are no non_blank cells" End sub |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 251
|
Ok I am filtering two column in one macro. If I filter first column with non blank cells, then it give me 3 rows, like row 2, 3,and 4. now I unfilter the first coulmn and filter the second column with non blank cells. does not matter if I filter any row or not, its selecting the range from row 2 through 4, becasue thats what I have in my codes. when I paste those values then I get strange numbers.
first column filter comes up like this rows: 2A 3A 4A now after filting second column when I copy and paste 2A 3A 4A even though I don't have any thing in second column filter, it should be blank. it is giving me the same values as column one. May be I describe the range in my macro. is there any way that when you filter, if you filter 2 rows then select only two rows, if after filtering row is blank then don't select row. Any help Please. Thanks |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|