Consulting

Results 1 to 3 of 3

Thread: VBA Code Modifcation To Insert a New Row and Fill out with Data As Per Existing Code

  1. #1

    VBA Code For Inserting a New Row and Filling Out with Data From Userform

    Hi All,

    I have this code which has been working fine, but i'm trying to use the same data for something else now. at the minute the code adds new information from the userform to the next row down, i'm wanting to change it so it adds an extra row above the data. will always be a new row 5. In my new code i need the cells to be fixed (C5, D5, E5 F5 ) with the new information only.

    'Write from form to ufDataPrivate Sub Summary()
        Dim ws As Worksheet, tgt As Range
        Set ws = Sheets("ufData")
        Set tgt = ws.Columns(1).Find(Me.tbProj)
        If tgt Is Nothing Then Set tgt = ws.Cells(Rows.Count, 1).End(xlUp)(2)
        With Me
            tgt.Resize(, 10) = Array(.tbProj, .tbOrder, .tbDelivery, .frEngineering.Tag, .frApproval.Tag, .frComp.Tag, .frMetal.Tag, .frProduction.Tag)
        End With
    End Sub
    Hope this makes sense.
    ND
    Last edited by nathandavies; 02-22-2018 at 09:16 AM.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Private Sub Summary()
      Dim ws As Worksheet
      Set ws =Sheets("ufData")
      ws.Rows("5:5").Insert
      With Me
        ws.Range("C5").Resize(, 8) = Array(.tbProj, .tbOrder, .tbDelivery, .frEngineering.Tag, .frApproval.Tag, .frComp.Tag, .frMetal.Tag, .frProduction.Tag)
      End With
    End Sub
    ?
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Thanks, Pascal this seems to have worked perfectly!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •