Passing a string value from one module to another without quotes in VB in Excel 2010

Posted on 2014-07-15
Last Modified: 2014-07-15

I am trying to pass the following string to a module.


When defining the string it is requiring me to put quotes around it.  However to use the string I do not want the quotes

I have this code to build it.
 strInList = "('" & strInList & "')"  

What do I do to be able to build the string and then use it, but without the quotes.

I want to my final result to be:

This string will be used in a query
Question by:morinia
    LVL 21

    Expert Comment

    by:Randy Poole
    are you using a query string to access your query or what?
    LVL 33

    Expert Comment

    If you are concatenating this string with another the " wouldn't be included.

    Author Comment

    I read in variables from an Excel column.  The variables were stringed together as above.  I am concatenating the variables to build the string that would be used in the query.

    Proc Sql;
       Create table active_members
          as  Select  a.*  from all_Members a
    where  memberid in .................... (this is where I am concatenating the string in VB)
    LVL 21

    Accepted Solution

    when you add the string to the query string your building the output of the string would be :
    dim sql as string
    dim ps as string
    sql="Create table active_members "
    sql=sql & "as  Select  a.*  from all_Members a "
    sql=sql & "where  memberid in " & ps

    Open in new window

    will be
    Create table active_members as  Select  a.*  from all_Members a where  memberid in ('8772282202','1356366002','0250079405')
    LVL 33

    Expert Comment

    As I said, when you concatenate the string the double quotes will not be included.
    strInList = "('8772282202','1356366002','0250079405')"
    strSQL =   "Create table active_members " &  _
                      "as  Select  a.*  from all_Members a " &  _
                      "where  memberid in "  & strInList
    MsgBox strSQL

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction This Article is a follow-up to my Mappit! Addin Article (, it was inspired by an email posting I made to EUSPRIG (, I will briefly cover: 1) An overvie…
    This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
    This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now