ExcelEndeavor
New Member
- Joined
- Oct 13, 2020
- Messages
- 49
- Office Version
- 365
- Platform
- MacOS
When clicking a command button in a userform, I am sending data to a worksheet ("PO Data"). This code uses a NumberFormat command with accounting format, but when I check the worksheet, it is still in currency format. I have column (G) in the worksheet formatted for accounting as well, so not sure why this is not formatted accurately. I use the same code on another userform that sends to a different worksheet and it works flawlessly. The accounting format line is towards the bottom. What might prevent the NumberFormat from formatting correctly in this instance?
Thank you in advance.
VBA Code:
Private Sub ButtonAddInvoice_Click()
'Declare worksheet variable
Dim rSh As Worksheet
On Error Resume Next
Set rSh = ThisWorkbook.Sheets("PO Data")
On Error GoTo 0
'If it is a new record
'Get the next available row
Dim nextRow As Long
If Label2 = "True" Then
nextRow = updateRow
MsgBox "Successfully Added"
Unload Me
Else
nextRow = rSh.Range("A" & Rows.Count).End(xlUp).Row + 1
End If
'Assign columns
rSh.Range("A" & nextRow).Value = RequestForm.TxtTeamLead
rSh.Range("B" & nextRow).Value = RequestForm.ComboBU
rSh.Range("C" & nextRow).Value = RequestForm.TxtPayee
rSh.Range("D" & nextRow).Value = RequestForm.TxtPONbr
rSh.Range("E" & nextRow).Value = TxtInvoiceNumber
rSh.Range("F" & nextRow).Value = TxtInvoiceDate
rSh.Range("G" & nextRow).Value = TxtInvoiceAmount
rSh.Range("H" & nextRow).Value = CheckboxPaidInvoice
'Change the CheckboxPaidInvoice output to "Paid" or ""
If Me.CheckboxPaidInvoice.Value = True Then
rSh.Range("H" & nextRow).Value = "Paid"
Else
rSh.Range("H" & nextRow).Value = ""
End If
' Activate the UpdateInvoiceList subroutine in the RequestForm userform
Call RequestForm.UpdateInvoiceList
'Format currency to accounting in worksheet
rSh.Range("G:G").NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
'Unload Me
clearForm
Unload Me
End Sub
Thank you in advance.