+ Reply to Thread
Results 1 to 4 of 4

Moving values from one text box to another.

  1. #1
    Registered User
    Join Date
    02-23-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Moving values from one text box to another.

    I've got a userform that will have 6 text boxes on it that show up one at a time when a value in the previous one gets a value.

    I want to make it so that if for example TextBox1, TextBox2, and TextBox3 currently have a value and TextBox4 is visible with no value. If the value in TextBox2 is deleted it will move the value of TextBox3 to TextBox2 and make TextBox4 not visible. Leaving TextBox3 visible with no value.

    It would do the same thing no matter how many of the textboxes had a value and one was deleted, always leaving 1 empty textbox

    I've tried searching the forms for something that would work but haven't had any luck.
    Last edited by justm3wi; 02-24-2013 at 03:25 PM.

  2. #2
    Forum Contributor
    Join Date
    12-31-2012
    Location
    Jhang, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Moving values from one text box to another.

    Try it...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-23-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Moving values from one text box to another.

    I get an error in the red line below when I try to run it. I'm not the best with VB code, it looks right to me.

    Private Sub ReArrangeValues()
    For i = 1 To 5
    If Me.Controls("TextBox" & i).Text = "" Then
    If Me.Controls("TextBox" & i + 1).Text <> "" Then
    Me.Controls("TextBox" & i).Text = Me.Controls("TextBox" & i + 1).Text
    Me.Controls("TextBox" & i + 1).Text = ""
    Else
    Me.Controls("TextBox" & i + 1).Visible = False
    End If
    End If
    Next
    End Sub

  4. #4
    Registered User
    Join Date
    02-23-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Moving values from one text box to another.

    I think I figured it out, I only had 5 textboxes on the userform I was trying it out on.

    I changed
    For i = 1 to 5

    to

    For i = 1 to 4

    And it appears to be working correctly.

    Thanks for the help
    Last edited by justm3wi; 02-24-2013 at 03:34 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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