cancel
Showing results for 
Search instead for 
Did you mean: 

VBA SAPSetFilter AO Excel - Multiple Values via name range

flo-g
Explorer
0 Kudos
916

Dear all,


I would like to give a list of more than 20000 text values (document numbers) as filter for an BW Query in Analysis for Office. This I would like to do via a short VBA code to automate. The Filter value shall be based on a variable list length. I have defined a variable name range in Excel and tried to use this name range then as filter input via the Application.Run SAPSet filter function. For this I am joining my variable area together in one string with a ; seperator.


For a limited amount of documents this does work. But as soon as it comes to a bigger list, I do receive a runtime error 1004. I guess the SapSetFilter function has an input limit. Do you have an idea to solve it? Is there a possibility to use the "Paste from Clipboard" function via VBA to use a Range filter in AO?

Sub Test()

Dim lresult As String

Dim rng As Range
Dim i As String
Dim SourceRange As Range

Set SourceRange = Range("MyRangeTest")

For Each rng In SourceRange
i = i & rng & ";"
Next rng

lresult = Application.Run("SAPSetFilter", "DS_3", "0DOC_NUMBER", i, "INPUT_STRING")

End Sub

When it comes to a big amount of data in the String i, it comes to this Runtime Error for the lresult row:

Thank you.

Accepted Solutions (0)

Answers (0)