+ Reply to Thread
Results 1 to 7 of 7

Macro Add row & add values in 2 different textbox

Hybrid View

  1. #1
    Registered User
    Join Date
    06-06-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2010
    Posts
    99

    Macro Add row & add values in 2 different textbox

    Attachment 195216Hi user's of excel forum!!

    Good Afternoon!

    I have a problem with add row & insert new values in textbox's
    I try to move the select cell to headers "Secondary VALUE" & "Quantity", but this move to other cells and don't stop.

    Attach the workbook and this is the code that I use:TEST PRICING TOOL.xlsm

    For ADD button:
    Private Sub CommandButton22_Click()
    
    Dim R
    
    With Sheets("CUSTOMIZED BOM")
      If Intersect(ActiveCell, .Range("A4:A7000")) Is Nothing Then GoTo einde
    Set R = .Columns(3).Find(ActiveCell, , xlValues, xlWhole)
     With R
      If Not .Offset(WorksheetFunction.CountIf(Columns(3), R), 2) = "C" Then
         .Offset(WorksheetFunction.CountIf(Columns(3), R), 2).EntireRow.Insert
         .Offset(WorksheetFunction.CountIf(Columns(3), R), 2) = "C"
      '
    '----Funcion para copiar la celda en "C", pero valida primero que tenga un valor en "E" para completar
    'En este caso es la funcion customizada "C", que agrega el valor..
          Dim c As Range
            Dim ws As Worksheet
            Dim lRow As Long
         
            For Each ws In Sheets
                With ws
                    lRow = .Range("E" & Rows.Count).End(xlUp).row
                    For Each c In .Range("E4:E" & lRow)
                        If c.Value <> vbNullString Then
                            If c.Offset(0, -2) = vbNullString Then
                                c.Offset(0, -2).Value = c.Offset(-1, -2).Value
                            End If
                        End If
                    Next c
                End With
            Next ws
         
    ' Se llama la funcion de proyectos y se duplica en los rangos
        With Range("B4:B" & Cells(Rows.Count, 3).End(xlUp).row)
                .NumberFormat = "General"
                .Formula = "=C$2"
            End With
    
    
    
    ' En Operation incluye un valor de cero
        With Range("H4:H" & Cells(Rows.Count, 3).End(xlUp).row)
                .Value = "0"
            End With
    
    ' En Extra Info incluye un espacio
        With Range("G4:G" & Cells(Rows.Count, 3).End(xlUp).row)
                .Value = " "
            End With
            
            
        Range("D4").End(xlDown).Offset(1, 0).Select
          newc.Show
      End If
     End With
        Exit Sub
       End With
    einde:  MsgBox "Only Select a cell in range A", , "Complete!"
    
    
    
    End Sub

    For TEXTBOX's:
    Private Sub CommandButton1_Click()
    Unload Me
    End Sub
    
    Private Sub TextBox2_Change()
    Dim myCell As Range
    Dim myTextBox As TextBox
     
    Set myCell = ActiveCell
    ActiveCell.Value = TextBox2.Text
    
    
    
    
    End Sub
    
    Private Sub TextBox3_Change()
    Range("F4").End(xlDown).Offset(1, 0).Select
    Dim myCell As Range
    Dim myTextBox As TextBox
    
    Set myCell = ActiveCell
    myCell.Value = TextBox3.Text
    End Sub
    Best Regards!!
    Last edited by feroguz; 11-20-2012 at 05:19 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Macro Add row & add values in 2 different textbox

    Can you better explain what you are trying to do and what the problem is?

  3. #3
    Registered User
    Join Date
    06-06-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2010
    Posts
    99

    Re: Macro Add row & add values in 2 different textbox

    Dear Sr:

    I require that the listbox2 & listbox3 are selected in cell "D" (Secondary Header VALUE) and "F" (Header Quantity Value) to add the new values ​​..

    The error that I have, is that only add function to find an empty value in the cell "D" but doesn't work the another function in value "F":
    This:
    Private Sub TextBox3_Change()
    Range("F4").End(xlDown).Offset(1, 0).Select

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Macro Add row & add values in 2 different textbox

    This adds the values to the next empty row in columns D and F when you click the command button. Is that what you want?

    Private Sub CommandButton1_Click()
        With Cells.Find("*", , , , xlByRows, xlPrevious)
            Range("D" & .row).Value = TextBox2.Value
            Range("F" & .row).Value = TextBox3.Value
        End With
        Unload Me
    End Sub
    Last edited by AlphaFrog; 11-20-2012 at 07:44 PM. Reason: typo

  5. #5
    Registered User
    Join Date
    06-06-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2010
    Posts
    99

    Re: Macro Add row & add values in 2 different textbox

    Hi Alphafrog:

    this function
    Private Sub CommandButton1_Click()
        With Cells.Find("*", , , , xlByRows, xlPrevious)
            Range("D" & .row).Value = TextBox2.Value
            Range("F" & .row).Value = TextBox3.Value
        End With
        Unload Me
    End Sub
    Is in the button of the application or in other section??.. because don't work me
    Other idea?

    Best Regards!!

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Macro Add row & add values in 2 different textbox

    It's in the newc userform code module.

    Sorry,it should be this...

    Private Sub CommandButton1_Click()
        With Cells.Find("*", , , , xlByRows, xlPrevious).Offset(1)
            Range("D" & .row).Value = TextBox2.Value
            Range("F" & .row).Value = TextBox3.Value
        End With
        Unload Me
    End Sub
    Last edited by AlphaFrog; 11-20-2012 at 08:35 PM.

  7. #7
    Registered User
    Join Date
    06-06-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2010
    Posts
    99

    Re: Macro Add row & add values in 2 different textbox

    Dear AlphaFrog:

    I remplace the code, because when performing this code the value added at the bottom of the sheet.

    Modify the code for this:

    Private Sub CommandButton1_Click ()
    
         With Range ("D4"). End (xlDown). Offset (1, 0)
         'Cells.Find ("*",,,, xlByRows, xlPrevious.) Offset (1)
             Range ("A" &. Row). Value = TextBox2.Value
             Range ("F" &. Row). Value = TextBox3.Value
         End With
         Unload Me
    
    End Sub
    And it works great!

    Attach the new worksheet for share:

    I have to thank you for always helping me, this is the second time.
    Thread closed
    Attached Files Attached Files

+ 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