Many execution of a query with different selections in the same work book

Hi all,
I have a workbook with one query that show sales of a plant. User can select many plants, but he doesn't like it, too easy. In this way query shows all the plant in the same sheet and he want a sheet for each plant.
The most simply way to do this is making a query for each plant with a filter with the plant as a constant. Then I put all that queries in the workbook. But this is not too smart, right?
Any suggestion?

Hi,
    I will try and explain here, if you get stuck and do get back.
1) On Sheet1 Rename it to BEX01 and Add the Query that will return all Plants. Hide this Sheet
2) On Sheet2 Rename it to BEX02 and Add the Main Query. Hide this Sheet.
3) On Sheet3 Rename it to Main and Add a Command Button. Goto Properties and Change the Name to cmdRefresh and then do View Code and add following code. 
Private Sub cmdRefresh_Click()
           Call RefreshReports
End Sub
4) Add a Module to your VBA Project
5) Open Module1 and Add following code.
Option Explicit
Public Sub RefreshReports()
    Dim wksBEX01 As Worksheet, wksBEX02 As Worksheet, wks As Worksheet
    Dim lRows As Long, lRow As Long
    Dim sPlant As String, sName As String
    Dim fRng As Range
    sName = "Main"
    With ThisWorkbook
        Set wksBEX01 = .Sheets("BEX01")
        Set wksBEX02 = .Sheets("BEX02")
    End With
    wksBEX01.Activate
    wksBEX01.Range("A1").Select
    'This will refresh both the Queries All Plants and the Main one.
    If Run("SAPBEX.XLA!SAPBEXrefresh", True) <> 0 Then
        MsgBox "Refresh of All Queries Failed."
        Exit Sub
    End If
    'Lets say your All Plants Query, Lists all the Plants Starting in Cell A15
    'Then Do the following.
    lRows = wksBEX01.Cells(Rows.Count, 1).End(xlUp).Row
    For lRow = 15 To lRows
        sPlant = Trim$(wksBEX01.Cells(lRow, 1).Value)
        'Now Use this Plant to Set the Filter Value for the Main Query.
        'I am assuming that your Plant Charateristic will show up in A14 on the Worksheet.
        With wksBEX02
            .Activate
            'Adjust this according to where you insert the Query and which cell has correct info.
            .Range("A14").Select
            Set fRng = Selection
        End With
        'Call the API to Do a Select Filter Value.
        If Run("SAPBEX.XLA!SAPBEXSetFilterValue", sPlant, "", fRng) <> 0 Then
            MsgBox "Unble to Set Filter for Plant : " & sPlant
            Exit Sub
        Else
            'Here you can Now Copy the the Sheet to new Sheet. If filter value worked.
             Set wks = ThisWorkbook.Sheets.Add(After:=sName)
             wksBEX02.Cells.Select
             wksBEX02.Copy
             wks.Range("A1").Paste
             wks.Name = sPlant
             sName = sPlant
        End If
    Next
     'Save the workbook as new name else you will have to first delete all the old sheets.    
     Thisworkbook.SaveAs "Some New Name"
End Sub
Here I have just created a new Sheet for Each Plant. You can work on the EXCEL Part to take and do what you want with new Sheets.
Hope this gets you started.
Just a Suggestion. Don't hide the BEX01 and BEX02 sheets untill the code works correctly.
Datta

Similar Messages

  • Unable to copy database with different name in the same instance

    I had a huge database and wanted to try some change optimization changes.
    So wanted to make a copy of the database along with data in the same instance.
    I have tried copy database wizard several times but always see the error as in attachment.
    Can someone let me know how to troubleshoot further?
    If this is not the correct way please suggest how do i copy a database with different name in the same instance along with data.

    Hi Nandu,
    From the screenshot, the error 1813 happens when corrupt database log is attempted to attach to the SQL Server. To work around this issue, please preform the following steps, for more details, please review this
    blog.
    1. Create a new database with same name which you want to recover. Make sure that the MDF file and LDF file have same name with previous database data and log file.
    2. Stop SQL Server. Move original MDF file from old location to new location by replacing just created MDF file. Delete the LDF file of new location just created.
    3. Start SQL Server. At this point, the database is in suspect status.
    4. Make sure that system tables of Master database allows to update the values. Please note that you will be performing this in query window.
    Use Master
    go
    sp_configure 'allow updates',1
    reconfigure with override
    go
    5. Change database mode to emergency mode.
    SELECT *
    FROM sysdatabases
    WHERE name = 'DatabaseName'
    BEGIN
    UPDATE sysdatabases
    SET status = 32768
    WHERE name = ' DatabaseName '
    COMMIT TRAN
    6. Restart SQL Server. Then execute the following DBCC command in query window to create new log file.
    DBCC TRACEON (3604)
    DBCC REBUILD_LOG(databasename,'c:\yourdatabasename_log.ldf')
    GO
    7. Reset the database status using following command.
    sp_RESETSTATUS yourdatabasename
    GO
    8. Turn off the update to system tables of Master database running following script.
    USE MASTER
    GO
    sp_CONFIGURE 'allow updates',0
    RECONFIGURE WITH OVERRIDE
    GO
    9. Reset the database status to previous status.
    BEGIN
    UPDATE sysdatabases
    SET status = (value retrieved in first query of step 5)
    WHERE name = 'DatabaseName‘
    COMMIT TRAN
    GO
    Make sure that you have done all the steps in order and restarted SQL Server where it is mentioned. Also run SQL Server Management Studio as administrator.(Right click-> Run as Administrator)
    Thanks,
    Lydia Zhang

  • Can two peeps use iChat with different accounts on the same computer?

    What do I do to REMOVE an old AIM account and replace it with a new account in IChat?
    Can two peeps use iChat with different accounts in the same computer?
    (Actually, two people share a laptop, but one of us cannot use her AIM account cuz mine is in iChat already... And, when traveling, I have the computer - and I would like to use iChat on the computer...)

    In iChat 4 you can have more than one AIM Valid name logged in at once.
    AIM valid = AIM, @mac.com or a MobileMe name.
    What you are then stuck with is that iChat is linked to one Buddy Picture and The one Mac User Account's Address Book which may or may not have Full Names, emails details, or a Nickname in iChat 4 linked to the Screen Names.
    Whilst it does let you both log in whilst using one Mac User Account there are drawbacks about who uses the keyboard and reading meesages from the other persons Buddies.
    8:50 PM Sunday; November 30, 2008

  • How can i share documents with different users on the same mac?

    How can i share documents with different users on the same mac?

    Shared how? The other users can read the documents or you all can read and write the documents?
    The first is easy just place the documents in /Users/Shared anyone can access the files there and the other users will be able to read them.
    The second is a bit trickier.

  • How can I share the home folder with different accounts on the same mac?

    Hi, here's a question:
    How can I share the home folder with different accounts on the same mac?
    The whole point being not to have to install all my apps, and move all my files each time between users.
    The second thing would be to be able to modify one document on one account, and have it changed on the other account without having to copy it.
    I would like to have a pro and a private account on my mac.
    Thanks for you answers,
    Doug

    Your apps should not be installed in your home folder--they should be in /Applications where every user can access them.
    If you want to share things between users on the same Mac, use the /Users/Shared folder. Keep your home folder private. Trying to defeat the protections on the home folder subfolders just gets messy. I've never bothered to figure out all of the problems associated with it so I can't explain how to do it.
    Even with using Shared, you would need to alter the ACLs on the shared folder in order to allow both users to modify the documents.
    You must create a Group in Users & Groups and put each user in that group. Then create a folder inside /Users/Shared where you want to share the various files.
    Then, add an ACL to the shared folder that gives the group special permissions. on that folder.
    sudo chmod -R +a "<sharinggroup> allow delete,chown,list,search,add_file,add_subdirectory,delete_child,file_inherit,directory_inherit" /Users/Shared/<sharing folder>
    Replace <sharinggroup> and <sharingfolder> with the name of your group and your folder. Then, run the command in the Terminal.
    With that ACL, each user in <sharinggroup> will be able to alter the files created by any user in the group in that <sharingfolder>.
    Essentially, the client OS is not designed for true file sharing among the individual users. It is designed to isolate each user account from the others.

  • Can I sync two ipods with different ID on the same computer?

    can I sync two ipods with different ID on the same computer?

    Hi,
    Yes you can as long as you have two seperate user accounts on your computer. Hope this helps.
    xxmitchxx90

  • Lost my playlists when I tried to share libraries with different accounts on the same MacBook computer

    lost my playlists when I tried to share libraries with different accounts on the same MacBook computer

    Hi dprette,
    When setting up iTunes to share a single music library between multiple user accounts on one computer you should follow the steps in this article -
    iTunes: How to share music between different user accounts on a single computer
    http://support.apple.com/kb/HT1203
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Mix source data with different granularity into the same fact table?

    I have two transaction tables "Incident (157 columns)" and "Unit (70 Colums)". For every "Incident" that happens there could be one or more records in the "Unit" table.
    As part of my data mart design, I have merged both the tables into a single Fact "Incident Fact (227 Columns)" and inserted the records from both the tables with a join condition between them [incident.IN_NUM = Unit.IN_NUM].
    Is this correct, is my question? or am I mixing source data with different granularity in the same fact table. Appreciate your help.
    Best Regards
    Bees

    Bees,
    Are the measures from 'Incident' , repeated for a given incident where it has more than one record in the Unit table ? If so, then the sum(indicent.measure) will give an incorrect result, no ?
    What requirement is there to physically merge the tables together outside of OBIEE? With OBIEE you could have one logical 'fact' table to present to report users, which sourced from seperate Incidents and Units tables and would stop the incorrect aggregations occuring. A common modelling piece in the same way would be Order Headers and Order Lines, quite common in OBIEE to have a logical 'Orders' fact which contained both Order header measures and Order line measures, this translates to your Incidents -> Units relationship.
    To do what I've mentioned, is relatively straight forward, you need a 'Dim - Incident' with two levels, Incident and Unit, mapp the unique identifiers in as the level keys and then use these levels to set the content levels correctly in your 2 logical tables sources for logical 'Fact' , ie Incidents LTS at incident level, Units LTS as units level.
    Hope this helps, let us know if you get stuck.
    Cheers
    Alastair

  • Invoice posting with different currency for the same PO

    Hi,
    Can we post the the Invoice with different currencies for the same PO.
    For example.
    PO has Qty 100 pcs.  amount 100 USD
    GR   Qty 100 pcs.
    Is it possible to post Invoice of 50 pc with 50 USD, and 50pcs with some other currency.
    Any sugggestions pls.
    Thanks,
    Satya

    Hello
    As per my knowledge, that is not possible.
    And in whjat scenario, we need to do that?
    In MIRO header itself we have the vendor currency, so it is not posbile to maintain different currency in different line items in MIRO.
    If you want, you can do MIRO in different currency that what is in PO.
    In the example given, you have o post 2 invoices, one for 50 qty in USD and the other 50 in different currency in other invoice transaction by giving the currency in basic data-invoice header and then only press ENTER after giving the PO number.
    Hope this helps
    Regards

  • How can I share applications and softwares with different users of the same computer?

    First question: How can I share applications and softwares with different users of the same computer?
    Second : Can I use 2 different I cloud accounts to synt 2 iphones with one computer?

    Applications installed on the admin account are available to all user accounts unless Parental Controls are enabled.
    Yes.   Separate user accounts, help here >   How to use multiple iPods, iPads, or iPhones with one computer

  • Sharing iMove Projects Libraries with different users on the same machine

    I was wonder how two different users on the same machine can
    share project libraries. Some Context:
    My daughter has some finished projects in her project library and
    I either want to import those project into my library or share them
    so both user accounts can access the projects (similar to how the
    event library is accessible)
    Note: I've already moving the project library to a shared disk (the one
    the event library is on) with no luck
    Using iMove 09
    tia...

    You need to move each project to the external drive from within iMovie. Be sure to use command-drag so you move, not copy.

  • Several layered effects of the same kind but with different adjustments for the same layer

    Hi,
    I wonder if it there is an easy way to have several different instances of e.g. glow or bevel and emboss on the same layer.
    I know I can achieve this by using smart objects or a duplicate layer with zero blending.
    I just wondered if there is a way to do this directly in the layer effects.

    Hi emil emil,
    thx for your answer!
    I wasn't even refering to different objects on the same layer, btw. it would be enough if I was able to layer e.g. different bevel and emboss on top of each other (With different colors, softness  and size.)  But I guess the answer remains the same.

  • Dashboard having same query with different selection screen values

    Hi,
    I want to create a dashboard by including different versions (different selection screen values, like yesterday, last week, last month) of same query. Is it possible to achieve it by without creating separate queries? We are in BI 7.
    Thanks in advance
    Nisha

    Hi,
    I want to create a dashboard by including different versions (different selection screen values, like yesterday, last week, last month) of same query. Is it possible to achieve it by without creating separate queries? We are in BI 7.
    Thanks in advance
    Nisha

  • When streaming video from a web site my audio is attenuated differently with different users on the same computer.  withe either user, the sound is very muffled.  all the volumes are set to maximum.

    How can I adjust the safari sound volume other than the usual settings in the system preferences?
    I am using an apple mac air, updated with OS X Yosemite.   Looking at the same web site video from two different users accounts on the same computer,  the sound is drastically attenuated on one user account relative to the other. 
    Sound settings in system preferences are maxed out.

    It seems that the difference between the sites that will open and the one that won't is the Default Authentication provider is set to NTLM on those that open, and Negotiate (Kerberos) on the one that won't. The Authentication Provider for the Default zone
    is Claims Based Authentication on all the sites, just site B (which won't open) is set to Negotiate (Kerberos), the others are set to NTLM.
    Short term: can I change the provider to NTLM without destroying the site?
    Long term: point me in the direction for setting up Kerberos correctly on my server/farm, as from what I can tell Kerberos is the recommended path forward. I'll setup a non-production test site and get it figured out.
    Thanks much.
    Steven

  • Sharing music with different users on the same computer

    Please help i can not configure my computer share music from the itunes library with others users whit different devices

    iTunes Home Sharing now works between users on same computer - https://discussions.apple.com/thread/3865597
    You could set up two completely separate libraries and share music via Home Sharing.
    iTunes: How to share music between different accounts on a single computer - http://support.apple.com/kb/HT1203 - relocating iTunes' media folder to a shared area but leaving separate library files - extra tip at https://discussions.apple.com/message/17331189
    Chris CA's instructions on sharing one iTunes music library between multiple user accounts - https://discussions.apple.com/message/8974074 - Multiple users using a single library file - similar post at: https://discussions.apple.com/thread/3753008
    Suggestion by Turingtest for multiple users and one library - http://discussions.apple.com/message/9117622 - use smart playlists and tags to isolate groupings.
    Discussions on using purchases from multiple AppleIDs in one iTunes library - https://discussions.apple.com/message/19543804

Maybe you are looking for

  • Attachments in Work Manager 6.0

    Attachments in Work Manager 6.0 work out of the box as far as allowing a user to attach a document, upload and download the document. However, we're not seeing any connection between attachments in WM and the SAP GUI. Attachments added to a Work Orde

  • Ipod keeps restarting/ wont show up in itunes or my computer...

    Recently my ipod has been freezing after listening to it for about 20-30 minutes, i would reset it and it would remain frozen after the reboot until the battery died. Now it wont even take a charge, it keeps showing the apple symbol then the unhappy

  • HP OFFICEJET PRO 8500A PLUS on Windows 2003 Server

    I'm trying to install the Windows 2003 driver for the HP OFFICEJET PRO 8500A PLUS but the installtion halts and says the operating system is not supported.  The O/S is fully patched. Does anyone have a go around for this?  I simply need it for Termin

  • Save 3d plot to excel as an image

    I am in the report phase of the project and would like to be able to save a 3D plot image (not the data) to an Excel spreadsheet. Any ideas? (The Print.Vi Invoke Node function methods for the front pane are not available in the RTE.) Solved! Go to So

  • WHAT ARE EVENTS IN A CLASSICAL REPORT ?

    WHAT ARE EVENTS IN A CLASSICAL REPORT ? PLEASE EXPLAIN THEM ? BEST REGARDS RYAN