Results 1 to 9 of 9

Convert a string to a TextBox name that VBA recognises

Threaded View

  1. #1
    Registered User
    Join Date
    04-28-2014
    Location
    Woodbridge VA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Convert a string to a TextBox name that VBA recognises

    ' I want to loop through TextBoxes and get their values
    ' In this simple test case, to insert them in spreadsheet cells A1 and A2

    ' VBA does nor recognize a string as a Textbox name and I have not been
    ' able to find a way to make this work.

    ' Any help would be very much appreciated!


    Sub Test()
    
    Dim iCount As Integer
    Dim strRange As String
    Dim strTextBoxName As String
    
    For iCount = 1 To 2
    
        strRange = "A" & CStr(iCount)
    
        strTextBoxName = "TextBox" & CStr(iCount)
        MsgBox ("strTextBoxName = " & strTextBoxName) 'check whether name is correct
     
        Range(strRange).Value = strTextBoxName.Value
    
    '   "Range(strRange).Value" works
    '                           "strTextBoxName.Value" does not work (I have tried a few variations)
    '   I need to convert the string "strTextBoxName" to a format which VBA recognises as a TextBox name.
    
    Next iCount
    
    End Sub
    Last edited by Leith Ross; 12-24-2014 at 05:49 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. add a string of locked text to vba textbox based on entry in the same textbox
    By yoursamrit2000 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-21-2014, 11:48 PM
  2. help to convert textbox value to negative based on another textbox value
    By lewisw in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-19-2014, 11:00 AM
  3. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  4. convert textbox value from string to either single or double numeric data type
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2011, 06:40 PM
  5. Userform: Convert textbox value from string to type long
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2011, 11:38 AM

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