PDA

View Full Version : [SOLVED:] VBA Code Modifcation To Insert a New Row and Fill out with Data As Per Existing Code



nathandavies
02-22-2018, 07:05 AM
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

p45cal
02-22-2018, 10:08 AM
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
?

nathandavies
02-23-2018, 07:42 AM
Thanks, Pascal this seems to have worked perfectly!