+ Reply to Thread
Results 1 to 2 of 2

Setting an object using multiple variants

  1. #1
    Registered User
    Join Date
    05-25-2010
    Location
    Florida
    MS-Off Ver
    Excel 2009
    Posts
    39

    Setting an object using multiple variants

    Hi,
    I am new to VBA and I am sure that this is a very basic question but I would really like to know how to do this.
    Sub test()
    Dim q As Variant
    Dim w As Variant
    Dim txtbox As Object
    q = "ActiveSheet.TextBox"
    w = "1"
    Set txtbox = q + w

    txtbox.Value = "xyz"

    End Sub

    I know that there is an easy way to do this but I want to create a macro that fills all text boxes with a certain text. That aside, the purpose of this post is to find out why is it that when I set "txtbox" as object using "q" and "w", I still get an error telling me that my object is required. Please help.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Setting an object using multiple variants

    You can edit your original post to add code tags.

    CodeTags.jpg

+ 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. [SOLVED] Setting an Object to a Variable
    By djbomaha in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-27-2012, 04:53 PM
  2. [SOLVED] Excel 2007 : Sumifs with Multiple variants
    By ncurran217 in forum Excel General
    Replies: 1
    Last Post: 04-20-2012, 11:06 AM
  3. [SOLVED] Searching for multiple names and variants
    By CFlack8472 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2012, 08:30 PM
  4. Write text to multiple cells using variants
    By therealjag in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-18-2009, 10:56 AM
  5. setting object variable
    By ndjxw17@yahoo.co.uk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2005, 03:06 PM

Tags for this Thread

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