If you only have one of 4 possibilities then I would use
a case statement instead of an array. For more
information on case statements
goto:
http://www.mvps.org/dmcritchie/excel/search.htm
Dim PERFORMANCE As Integer
Select Case PERFORMANCE
Case 100
Bonus = salary * 0.1 'if variable PERFORMANCE 100
Case 75
Bonus = salary * 0.075 'if variable PERFORMANCE 75
Case 50
Bonus = salary * 0.05 'if variable PERFORMANCE 50
Case 25
Bonus = salary * 0.025 'if variable PERFORMANCE 25
Case 10
Bonus = salary * 0.01 'if variable PERFORMANCE 10
End Select
-----Original Message-----
This is similiar to a previous post but I think I have
my problem reduced even further. I think all I need here
is to set up an array and pass the value of that through
my current macro. There are 4 places were the value of
the array would need to be inputed (as seen below <--
Value From Array--). The values for the array will be
on "sheet2" of the "ReportOne.xls" file, in
column "E".There will be anywhere from 1 to 4 values
there. The data that the autofilter is filtering will be
on "sheet1" of "ReportOne.xls". I need to loop through
my current macro passing into it in those four places
each value from the array.
My problem is I don't really know how to use arrays,
especially in this manner - I think it is all I need -
and this is the only solution I can put together that can
come close to figuring out for my problem. Any help on
this would be great. This is as far as I can take this
alone.
Sub FindOrCreate()
Application.DisplayAlerts = False
Dim MyPath As String
Dim sh As Worksheet
Workbooks.Open (ThisWorkbook.Path & "\ReportOne.xls")
Set sh = ActiveWorkbook.ActiveSheet
With sh
.Columns("A:I").AutoFilter Field:=8, Criteria1:= <--
Value From Array--
.Columns("A:I").SpecialCells(xlCellTypeVisible).Co py
If Dir(ThisWorkbook.Path
& "\ProgramData\FileData\StoredData\ <--Value From Array--
") < "" Then
'Open
Workbooks.Open (ThisWorkbook.Path
& "\ProgramData\FileData\StoredData\ _
<--Value From Array--" & ".xls")
Else
'Create
Workbooks.Add
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete
End If
Sheets("Sheet1").Range("A1").PasteSpecial
.Columns("I:I").AutoFilter
.SaveAs Filename:=ThisWorkbook.Path
& "\ProgramData\FileData\StoredData\ _
<--Value From Array--" & ".xls")
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
.Close
End With
Application.DisplayAlerts = True
End Sub
Thanks in advance for your time,
Jim
.