+ Reply to Thread
Results 1 to 4 of 4

Find and replace

Hybrid View

  1. #1
    Registered User
    Join Date
    06-16-2011
    Location
    phoenix, az
    MS-Off Ver
    Excel 2007
    Posts
    2

    Find and replace

    Im trying to create a gui so my employees can update our inventory without having to touch the data. The program prompts them for all sorts of infomation. At the end i want it to take txtLocation, find it in the workbook and replace it with all data that has been entered(multiple cells). As of right now it just places the data in the next available of a very specific sheet.
    Private Sub cmdAdd_Click()
    
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("NewData")
    
    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 1) _
      .End(xlUp).Offset(1, 0).Row
    
    'check for a part number
    If Trim(Me.txtLocation.Value) = "" Then
      Me.txtLocation.SetFocus
      MsgBox "Please enter a Location"
    'ElseIf Trim(Me.txtSuperiorOrderNumber.Value) = "" Then
     ' Me.txtLocation.SetFocus
      'MsgBox "Please enter a Superior Order Number"
    'ElseIf Trim(Me.txtSerialNumber.Value) = "" Then
     ' Me.txtLocation.SetFocus
      'MsgBox "Please enter a Serial Number"
    'ElseIf Trim(Me.txtEngineType.Value) = "" Then
      'Me.txtLocation.SetFocus
      'MsgBox "Please enter Engine Type"
    'ElseIf Trim(Me.txtCustom.Value) = "" Then
      'Me.txtLocation.SetFocus
      'MsgBox "Please enter Customer"
    'ElseIf Trim(Me.txtTraced.Value) = "" Then
      'Me.txtLocation.SetFocus
      'MsgBox "Please enter whether it has been traced or not"
      Exit Sub
    End If
    'copy the data to the database
    ws.Cells(iRow, 1).Value = Me.txtLocation.Value
    ws.Cells(iRow, 2).Value = Me.txtSuperiorOrderNumber.Value
    ws.Cells(iRow, 3).Value = Me.txtSerialNumber.Value
    ws.Cells(iRow, 4).Value = Me.txtEngineType.Value
    ws.Cells(iRow, 5).Value = Me.txtCustom.Value
    ws.Cells(iRow, 6).Value = Me.txtTraced.Value
    
    
    
    
    End Sub
    Last edited by Leith Ross; 06-16-2011 at 02:49 PM. Reason: Added Code Tags

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,994

    Re: Find and replace

    Can't really test and amend this without workbook, worksheets, typical data, forms and code.

    Please upload a sample workbook.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-16-2011
    Location
    phoenix, az
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Find and replace

    sorry here is an example excel sheet.
    Attached Files Attached Files

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,994

    Re: Find and replace

    Is there meant to be a data entry form and code in this workbook? Only there isn't.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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