+ Reply to Thread
Results 1 to 4 of 4

Convert Strings to Object

  1. #1
    Registered User
    Join Date
    03-01-2013
    Location
    southafrica
    MS-Off Ver
    Excel 2003
    Posts
    8

    Convert Strings to Object

    Hi,

    am constructing range query dynamically. see below

    I am storing result in rngData1 variable. It is a string. when i display it with msgbox it works fine.

    It's not working when i try to set that as my Object .

    It work if hardcode it like - Set rngData = ActiveSheet.Range("A1:A500000,B1:B500000")

    If Sheets("SearchSheet").Range("M9").Value = True Then
    bu = "A2:A500000,"
    Else
    bu = "H1:I1,"
    End If

    If Sheets("SearchSheet").Range("M11").Value = True Then
    Fa = "B2:B500000"
    Else
    Fa = "H1:I1"
    End If

    rngData1 = "ActiveSheet.Range(" & Chr(34) & bu & Fa & Chr(34) & ")"

    Set rngData = rngData1 ---- issue here .can't place string in object rngdata
    Last edited by vairam; 03-07-2013 at 07:45 AM. Reason: solved

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Convert Strings to Object

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Convert Strings to Object

    Hi, vairam,

    welcome to ExcelForum. P.lease put Code-tags around the code displayed as requested in Forum Rule #3. Thanks

    Try using Union:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    03-01-2013
    Location
    southafrica
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Convert Strings to Object

    That works Thanks a lot Patel.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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