+ Reply to Thread
Results 1 to 6 of 6

userform and active cell.

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

    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
    MO Prof Plus 2016
    Posts
    6,907

    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, England
    MS-Off Ver
    365
    Posts
    15,029

    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
    11

    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
    MO Prof Plus 2016
    Posts
    6,907

    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, England
    MS-Off Ver
    365
    Posts
    15,029

    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)

Similar Threads

  1. Userform send text box to active cell
    By pvuv in forum Excel General
    Replies: 2
    Last Post: 03-05-2019, 09:39 AM
  2. TextBox in UserForm to mirror format of active cell
    By Un-Do Re-Do in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2017, 11:34 PM
  3. [SOLVED] Userform better coding to make a cell the active cell
    By Apache_sim in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2015, 02:30 AM
  4. [SOLVED] Adding active Hyperlink to a cell using UserForm
    By pipoliveira in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-10-2015, 07:51 AM
  5. [SOLVED] Userform textbox to reference active cell with offset
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 6
    Last Post: 12-15-2013, 01:38 AM
  6. [SOLVED] Userform to add data to active cell offset
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 2
    Last Post: 12-14-2013, 07:58 PM
  7. Excel VBA: Move Userform Based on Active Cell?
    By Dale Maggee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2005, 03:05 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