Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel macro
I have recorded two macroes, put them together and added if-then-else
statement, but there is something wrong. It does not work. Both macroes work fine separately. I try to filter data from a base workbook to an active workbook and make it run automatically every time when the file is opened. Excel should check if a base file is open and if so run the filter routine. If that file is not open it should be opened and run filter. Sub macroname() If IsFileOpen("\\serverName\path\fileName.xls") Then Workbooks("fileName.xls").Sheets("Sheet1").Range(" rangeName1"). _ AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("rangeNames"), _ CopyToRange:=Range("rangeName3"), Unique:=False Else Workbooks.Open(Filename:= _ "\\serverName\path\fileName.xls").RunAutoMacro s _ Which:=xlAutoOpen ActiveWindow.WindowState = xlMaximized Workbooks("tuotantoalueet.xls").Sheets("Sheet1").R ange("trangeName1"). _ AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("rangeName2"), _ CopyToRange:=Range("rangeName3"), Unique:=False End If End Sub It is not difficult or is it? Excel seems to need some function, but my knowledge about programming excel macroes is rather weak. Any hints or a piece of code. Thanks in advange hk |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel macro
Post back and cite the error message that you get and what line of code
produced the error. What is "IsFileOpen"? HTH Otto wrote in message oups.com... I have recorded two macroes, put them together and added if-then-else statement, but there is something wrong. It does not work. Both macroes work fine separately. I try to filter data from a base workbook to an active workbook and make it run automatically every time when the file is opened. Excel should check if a base file is open and if so run the filter routine. If that file is not open it should be opened and run filter. Sub macroname() If IsFileOpen("\\serverName\path\fileName.xls") Then Workbooks("fileName.xls").Sheets("Sheet1").Range(" rangeName1"). _ AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("rangeNames"), _ CopyToRange:=Range("rangeName3"), Unique:=False Else Workbooks.Open(Filename:= _ "\\serverName\path\fileName.xls").RunAutoMacro s _ Which:=xlAutoOpen ActiveWindow.WindowState = xlMaximized Workbooks("tuotantoalueet.xls").Sheets("Sheet1").R ange("trangeName1"). _ AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("rangeName2"), _ CopyToRange:=Range("rangeName3"), Unique:=False End If End Sub It is not difficult or is it? Excel seems to need some function, but my knowledge about programming excel macroes is rather weak. Any hints or a piece of code. Thanks in advange hk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Help In Excel | Excel Discussion (Misc queries) | |||
Closing File Error | Excel Discussion (Misc queries) | |||
Macro to close excel | Excel Discussion (Misc queries) | |||
passing arguments from an excel macro to a word macro | Excel Discussion (Misc queries) | |||
Excel macro that opens new MS Word file and pastes data as a pictu | Excel Worksheet Functions |