+ Reply to Thread
Results 1 to 6 of 6

Space Issue in macro typical scenario

Hybrid View

  1. #1
    Registered User
    Join Date
    03-09-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    85

    Space Issue in macro typical scenario

    Hi,

    I have written one macro to get the data count from Oracle Database tables using excel macro.Its working fine but the problem is,i have lot of tables so I mentione all the tables in sql query that query im using in macro to get the results.When I use that sql with 2 or 10 table names that sql will be in one line in my code so it is working.but if I use more tables it is coming to another lines because of sql querry length.Because of that my sql is not working.

    Sample sql used in macro working for less no of tables.I defined like,
    strSQL="SELECT TABLENAME,COUNT(*) FROM BASETABLES WHERE TABLENAME IN('TABLE1','TABLE2')
    The above one is working because entire script in same line.

    Failing scenario:
    strSQL="SELECT TABLENAME,COUNT(*) FROM BASETABLES WHERE TABLENAME IN('TABLE1','TABLE2',
    'table4',...........................................................
    'table60'...................................................'Table100')

    wat is happening above code is sql querry comes down to second line here it is starting with " ' " symobol.bcz of that macro considering it as comments.

    Any one can please help me on this....

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Space Issue in macro typical scenario

    You can split long lines in VBA using underscore followed by space
    strsql = "SELECT TABLENAME,COUNT(*) FROM BASETABLES WHERE TABLENAME IN('TABLE1','TABLE2'," & _
    "'Table3',...................."
    ________________________________________________________
    If your problem is solved, update the thread as SOLVED: Go to the top of the first post-Select Thread Tools-Select Mark thread as Solved OR - Go to the first post - Click edit- Click Advance- Just below the word "Title:" you will see a dropdown with the word No prefix.- Change to Solve- Click Save.

    Show your gratitude to the person who helped you solving your problem by clicking on star button at the bottom of such post.

  3. #3
    Registered User
    Join Date
    03-09-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Space Issue in macro typical scenario

    Hi Hari,

    Thx for the reply.Little bit confusing for me.Can you please give some example script for some tables.

  4. #4
    Registered User
    Join Date
    03-09-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Space Issue in macro typical scenario

    Any one can help on this issue...

  5. #5
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Space Issue in macro typical scenario

    Or consider using Chr(39) in place of apostrophe

  6. #6
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Space Issue in macro typical scenario

    Sorry, I don't have any sample codes. I just used your code to come in 2 lines. See below. Paste it in your code and see, only for 3 tables.
    strsql = "SELECT TABLENAME,COUNT(*) FROM BASETABLES WHERE TABLENAME IN('TABLE1','TABLE2'," & _
    "'Table3'"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro for Typical scenario
    By toravietl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2014, 08:31 AM
  2. Scenario Drop Down Issue
    By ExcelNoob9 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2013, 12:44 AM
  3. Scenario Manager displays same result for every scenario
    By terihoff in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 11-10-2012, 07:14 PM
  4. Double Space Issue
    By darshan_parekh in forum Excel General
    Replies: 3
    Last Post: 11-26-2011, 12:45 PM
  5. Not the typical "find, delete" row issue --need urgent help please!
    By Dragon120 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2007, 12:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1