+ Reply to Thread
Results 1 to 4 of 4

Don't change data if textbox is blank.

Hybrid View

  1. #1
    Registered User
    Join Date
    05-16-2012
    Location
    chance ingaic
    MS-Off Ver
    Excel 2010
    Posts
    3

    Don't change data if textbox is blank.

    Hi, I'm in a need for help.
    Created a userform to view data and another one to change it, the userform where you can change data on sheet shouldnt change data on sheet if there's no data in the textbox. Just cant figure out how to make it skip that textbox and not to change existing data as a blank cell, but still fill in from the other textboxes that have data in them. Also using combobox. This is the code for the submit changes button.
    
    
    Private Sub Muuda_Click()
    
     ActiveCell.Offset(0, 2) = Me.stattcob.Value
    
    If Me.stattcob.Value = "" Then
       'What do i need to add here for it to skip/ignore it then
    Else
          ActiveCell.Offset(0, 2) = Me.stattcob.Value
    
    End If
     
    
     ActiveCell.Offset(0, 4) = Me.kuup.Value
     
    If Me.kuup.Value = "" Then
          'What do i need to add here for it to skip/ignore it then
    Else
          ActiveCell.Offset(0, 2) = Me.kuup.Value
    
    End If
    
      ActiveCell.Offset(0, 5) = Me.krittcob.Value
    If Me.krittcob.Value = "" Then
          'What do i need to add here for it to skip/ignore it then
    Else
          ActiveCell.Offset(0, 2) = Me.krittcob.Value
    
    End If
    
       ActiveCell.Offset(0, 7) = Me.osacob.Value
    If Me.osacob.Value = "" Then
          'What do i need to add here for it to skip/ignore it then
    Else
          ActiveCell.Offset(0, 2) = Me.osacob.Value
    
    End If
    
    End Sub
    Last edited by martino; 05-18-2012 at 02:10 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,658

    Re: Don't change data if textbox is blank.

    maybe:

    If Me.kuup.Value <> "" Then
          ActiveCell.Offset(0, 2) = Me.kuup.Value
    End If
    and so on

  3. #3
    Registered User
    Join Date
    05-16-2012
    Location
    chance ingaic
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Don't change data if textbox is blank.

    Hm it's still overwriting the existing data. I'l try to give you more info.
    workbook.jpg
    As you can see from the picture, Below the "Kuva andmed" it has searched the info from the project x1234, as seen the "Tellija" textbox is empty as it hasnt been inserted yet to the database. On the right side you see the "Muuda andmeid" frame, from there you can change the info of the current project row. Now that i only need to put in the "Tellija" since it's the only one empty i need the other textbox'es to be ingored and not to change the data i already have. At the moment if i press the "Muuda andmeid" button, it will make every cell a blank one if i dont insert something in the textboxes.

  4. #4
    Registered User
    Join Date
    05-16-2012
    Location
    chance ingaic
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Don't change data if textbox is blank.

    Did a workaround no help needed anymore. Thank you Zbor for the reply.
    In addition the workaround is just that it takes the data it already has also do the "Muuda andmeid" form.
    So it will overwrite the data with the same value it already has if i don't make a change do it.
    Last edited by martino; 05-18-2012 at 05:09 AM.

+ 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