K
Khalil Handal
Hi, I hope that some one can help!
I want to take a certain range of cells in the file "HCP_2005_upgrade" and
filter so as to select all the cells that are not empty.
Then select all the rows for these cells and copy them to a new workbook
"W_V" in "sheet2". I have the following code.
Three problems:
1- When copying to the new workbook I did not have the same
column width. What should I do in order to have the same column width?
2- What code do I need to add, and where, so as to let the
macro automatically find the last row that is not empty (particularly in
column B). Select only the filtered range.
3- My sheet is protected. The auto filter only works for
unprotected sheets. How can I overcome this problem or go around it. (i.e.
to do filtration for protected sheets).
The code is:
Sub Macro1()
Range("EI16:EI159").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<>"
Rows("1:44").select --à (what code do I need so that the macro do this
automaticaly since it changes often).
Workbooks.Open Filename:="H:\W_V.xls"
Sheet("Sheet2").Select
Selection.PasteSpecial Paste:x1PasteColumnWidths, Operation:=x1None,_
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
Range("E7").Select
ActiveWindow.FreezePanes=True
Windows("HCP_2006_Upgrade.xls").Activate
Range("A16").Select
Application.CutCopyMode=False
Selection.AutoFilter
Range("A1").Select
End Sub
Khalil
I want to take a certain range of cells in the file "HCP_2005_upgrade" and
filter so as to select all the cells that are not empty.
Then select all the rows for these cells and copy them to a new workbook
"W_V" in "sheet2". I have the following code.
Three problems:
1- When copying to the new workbook I did not have the same
column width. What should I do in order to have the same column width?
2- What code do I need to add, and where, so as to let the
macro automatically find the last row that is not empty (particularly in
column B). Select only the filtered range.
3- My sheet is protected. The auto filter only works for
unprotected sheets. How can I overcome this problem or go around it. (i.e.
to do filtration for protected sheets).
The code is:
Sub Macro1()
Range("EI16:EI159").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<>"
Rows("1:44").select --à (what code do I need so that the macro do this
automaticaly since it changes often).
Workbooks.Open Filename:="H:\W_V.xls"
Sheet("Sheet2").Select
Selection.PasteSpecial Paste:x1PasteColumnWidths, Operation:=x1None,_
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
Range("E7").Select
ActiveWindow.FreezePanes=True
Windows("HCP_2006_Upgrade.xls").Activate
Range("A16").Select
Application.CutCopyMode=False
Selection.AutoFilter
Range("A1").Select
End Sub
Khalil