Trueblue862
Board Regular
- Joined
- May 24, 2020
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
Hi, I have this code which adds values to a range of data from a userform. Is there a way to get it to also add formulas to Columns F, I, J, L, M, and N? I have tried copy and paste codes which really don't seem to play nice with the rest of the data in the sheet. I have the following formulas in the sheet:
Column F: =IFERROR((E3/C3),"")
Column I: =((C3*D3)+G3)-H3
Column J: =IFERROR((E3/C3),"")
Column L: =IFERROR((K3-J3),"")
Column M: =IFERROR(H3*L3,"")
Column N: =IFERROR(((M3)-(I3*J3)),"")
All of these formulas are from row 3, I need them to be input into the sheet in the correct columns and in such a way they will become dynamic in the sheet and adjust to their new location when the sheet sorts alphabetically.
I really appreciate any help with this.
Column F: =IFERROR((E3/C3),"")
Column I: =((C3*D3)+G3)-H3
Column J: =IFERROR((E3/C3),"")
Column L: =IFERROR((K3-J3),"")
Column M: =IFERROR(H3*L3,"")
Column N: =IFERROR(((M3)-(I3*J3)),"")
All of these formulas are from row 3, I need them to be input into the sheet in the correct columns and in such a way they will become dynamic in the sheet and adjust to their new location when the sheet sorts alphabetically.
VBA Code:
Private Sub StoreValues()
Dim rw As Integer
Dim ws As Worksheet
Set ws = Worksheets("Order Sheet")
rw = ws.Cells.Find(what:="*", searchorder:=xlRows, Searchdirection:=xlPrevious, LookIn:=xlValues).Row + 1
ws.Cells(rw, 1).Value = Me.TbxProd.Value
ws.Cells(rw, 2).Value = Me.CbxUnit.Value
End Sub
I really appreciate any help with this.