The code below copies data (Associate Entry named range) and pastes it into the particular row number (1RecRow) in a different sheet (AssociateData).
I would like the row to be pasted to all the rows ONLY BELOW the numbered row.
There are a couple of things to bear in mind:
A. The data is filtered and I would like the pasting to affect rows below "1 RecRow" within the filtered view (not ALL - unfiltered - data).
B. If it helps, the data is sorted in a way if the "1 RecRow" is 23, then the next row is 24, 25, 26, 27 (in order).
So manually I would do it in this way: Paste the data in the particular row, copy the data again from 1 RecRow, Ctrl+Shift+Down arrow and Paste. I'm just not sure how to adjust the code so that it performs it.
Thanks
E
I would like the row to be pasted to all the rows ONLY BELOW the numbered row.
There are a couple of things to bear in mind:
A. The data is filtered and I would like the pasting to affect rows below "1 RecRow" within the filtered view (not ALL - unfiltered - data).
B. If it helps, the data is sorted in a way if the "1 RecRow" is 23, then the next row is 24, 25, 26, 27 (in order).
So manually I would do it in this way: Paste the data in the particular row, copy the data again from 1 RecRow, Ctrl+Shift+Down arrow and Paste. I'm just not sure how to adjust the code so that it performs it.
Code:
Sub UpdateLogRecord()
Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim lRec As Long
Dim oCol As Long
Dim lRecRow As Long
Dim myCopy As Range
Dim myTest As Range
Dim lRsp As Long
Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("AssociateData")
oCol = 3 'associate info is pasted on data sheet, starting in this column
'check for duplicate order ID in database
If inputWks.Range("CheckAssNo") = False Then
lRsp = MsgBox("Order ID not in database. Add record?", vbQuestion + vbYesNo, "New Order ID")
If lRsp = vbYes Then
UpdateLogWorksheet
Else
MsgBox "Please select Order ID that is in the database."
End If
Else
'cells to copy from Input sheet - some contain formulas
Set myCopy = inputWks.Range("AssociateEntry")
lRec = inputWks.Range("CurrRec").Value
lRecRow = lRec + 1
With inputWks
Set myTest = myCopy.Offset(0, 2)
If Application.Count(myTest) > 0 Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With
With historyWks
With .Cells(lRecRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(lRecRow, "B").Value = Application.UserName
myCopy.Copy
.Cells(lRecRow, 3).PasteSpecial Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
End With
'clear input cells that contain constants
ClearDataEntry
End If
End Sub
Thanks
E
Last edited: