+ Reply to Thread
Results 1 to 6 of 6

userform and active cell.

  1. #1
    Registered User
    Join Date
    09-17-2007
    Posts
    10

    Exclamation userform and active cell.

    hello excel users.
    i have a userform which populates the active cell with data entered inthe userform text box. however there is an issue if the active cell has data already present it should be shown in that text box. it is not doing that. so when i write anything in the text box it overrides the old data causing discrepencies.
    when the active cell contains NJ:N=80,V6=0,V9=0, it should populate text box in user for NJ. and if active cell contains UV:N=140,V6=0,V9=0 then it should populate the textbox for UV.

    Please help. attaching sample Excel

    current code:
    Private Sub CommandButton1_Click()
    Dim s13 As String, s14 As String, s15 As String, sTxt
    Dim d16 As String, d17 As String, d18 As String, dTxt

    s13 = Me.TextBox13
    s14 = Me.TextBox14
    s15 = Me.TextBox15
    d16 = Me.TextBox16
    d17 = Me.TextBox17
    d18 = Me.TextBox18

    If s13 <> "" And s14 <> "" And s15 <> "" Then
    sTxt = "NJ:N=" & s13 & ",V6=" & s14 & ",V9=" & s15
    ActiveCell = sTxt
    End If

    If d16 <> "" And d17 <> "" And d18 <> "" Then
    dTxt = "UV:N=" & d16 & ",V6=" & d17 & ",V9=" & d18
    ActiveCell = dTxt
    End If

    Unload Me
    End Sub



    screenshots:

    curent:
    1.PNG

    how it shoudl be:
    NJ.PNG

    UV.PNG

    many tahnks for your help in this matter.
    Attached Files Attached Files

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    6,458

    Re: userform and active cell.

    You should test the activecell on opening your Userform, using the Userform_Initialize event.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham
    MS-Off Ver
    365
    Posts
    6,532

    Re: userform and active cell.

    How about, for NJ
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-17-2007
    Posts
    10

    Re: userform and active cell.

    it worked like a charm. did it for other segment aswel. many thanks

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    6,458

    Re: userform and active cell.

    Good luck with your project and thanks for rep+.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham
    MS-Off Ver
    365
    Posts
    6,532

    Re: userform and active cell.

    Glad to help & thanks for the feedback

+ 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