Need Revised VBA for User Form data

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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi, lhuddleston. Welcome to the Forum.
If I understand you correctly, maybe this:
Add the blue line:
Rich (BB code):
.Cells(1, 17) = ExpenseAcct.Value
.Cells(1, 1).Offset(-1).Copy .Cells(1, 1)

If SamePOYes.Value = True Then
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top