lhuddleston
New Member
- Joined
- Jun 26, 2019
- Messages
- 2
Hello,
I have a pretty crazy workbook that contains the following coding for a User Form. This particular code is entering data into a table for Purchase Orders. I have all of the cells working and adding the correct data, and the other columns that have formulas copy down as they should, EXCEPT for the very first column that creates purchase order numbers. It is somewhat numeric (the last couple of numbers) but the other data that creates the PO comes from the user and date. It is pretty convoluted.....anyway I need to add to my vba to copy for formula for the cell above the last row I am entering in column 1 so I can copy the formula into the new row. Gosh, I hope this makes sense. Everything else in the code works, just need column 1 to keep copying the formula down as rows are added.
Private Sub EnterPO_Click()
Dim LastRow As Range
Dim POListingTable As ListObject
'Add row to bottom of PO Listing table
Sheet1.ListObjects("POListing").ListRows.Add
'Enter data from form into our new row
Set POListingTable = Sheet1.ListObjects("POListing")
Set LastRow = POListingTable.ListRows(POListingTable.ListRows.Count).Range
With LastRow
.Cells(1, 7) = ChosenDate.Value
.Cells(1, 4) = RequestedBy.Value
.Cells(1, 8) = Company.Value
.Cells(1, 10) = Description.Value
.Cells(1, 9) = ItemNumber.Value
.Cells(1, 11) = Quantity.Value
.Cells(1, 12) = Unit.Value
.Cells(1, 13) = UnitPrice.Value
.Cells(1, 17) = ExpenseAcct.Value
If SamePOYes.Value = True Then
.Cells(1, 2) = "Yes"
Else
.Cells(1, 2) = "No"
End If
If SalesTaxYes.Value = True Then
.Cells(1, 14) = "Yes"
Else
.Cells(1, 14) = "No"
End If
End With
End Sub
I have a pretty crazy workbook that contains the following coding for a User Form. This particular code is entering data into a table for Purchase Orders. I have all of the cells working and adding the correct data, and the other columns that have formulas copy down as they should, EXCEPT for the very first column that creates purchase order numbers. It is somewhat numeric (the last couple of numbers) but the other data that creates the PO comes from the user and date. It is pretty convoluted.....anyway I need to add to my vba to copy for formula for the cell above the last row I am entering in column 1 so I can copy the formula into the new row. Gosh, I hope this makes sense. Everything else in the code works, just need column 1 to keep copying the formula down as rows are added.
Private Sub EnterPO_Click()
Dim LastRow As Range
Dim POListingTable As ListObject
'Add row to bottom of PO Listing table
Sheet1.ListObjects("POListing").ListRows.Add
'Enter data from form into our new row
Set POListingTable = Sheet1.ListObjects("POListing")
Set LastRow = POListingTable.ListRows(POListingTable.ListRows.Count).Range
With LastRow
.Cells(1, 7) = ChosenDate.Value
.Cells(1, 4) = RequestedBy.Value
.Cells(1, 8) = Company.Value
.Cells(1, 10) = Description.Value
.Cells(1, 9) = ItemNumber.Value
.Cells(1, 11) = Quantity.Value
.Cells(1, 12) = Unit.Value
.Cells(1, 13) = UnitPrice.Value
.Cells(1, 17) = ExpenseAcct.Value
If SamePOYes.Value = True Then
.Cells(1, 2) = "Yes"
Else
.Cells(1, 2) = "No"
End If
If SalesTaxYes.Value = True Then
.Cells(1, 14) = "Yes"
Else
.Cells(1, 14) = "No"
End If
End With
End Sub