H
harri.kukkonen
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").RunAutoMacros _
Which:=xlAutoOpen
ActiveWindow.WindowState = xlMaximized
Workbooks("tuotantoalueet.xls").Sheets("Sheet1").Range("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
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").RunAutoMacros _
Which:=xlAutoOpen
ActiveWindow.WindowState = xlMaximized
Workbooks("tuotantoalueet.xls").Sheets("Sheet1").Range("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