In Userform, when data entry, the value doesn't show as Value e.g. doolars or dates

kitsa

Board Regular
Joined
Mar 4, 2016
Messages
111
Office Version
  1. 365
  2. 2016
Hi Guys,
I would like to enter figures into Userform, but would like it to show as Dollars "$#,##0.00" or dates "mm/dd/yyyy", how do I do this?
UserForm_Dollars.JPG


VBA Code:
Sub Reset()

    Dim iRow As Long

iRow = [Counta(Database!A:A)] ' idetifying the last row



With frmForm

.TxtCompanyName.Value = ""
.txtProjectName.Value = ""
.TxtDate.Value = ""
.TxtNo.Value = ""


.CmbConVar.Clear

.CmbConVar.AddItem "Subcontract"
.CmbConVar.AddItem "Variation"

.TxtRowNumber.Value = ""


.TxtQuoteNo.Value = ""
.TxtItemNo.Value = ""
.TxtArea.Value = ""
.TxtDes1.Value = ""
.TxtDes2.Value = ""
.TxtHeight.Value = ""
.TxtLength.Value = ""
.TxtLevels.Value = ""
.TxtErect.Value = ""
.TxtHUI1.Value = ""
.TxtHUI2.Value = ""
.TxtHUI3.Value = ""
.TxtSTD.Value = ""
.TxtLCS.Value = ""
.TxtIB.Value = ""
.txtTMNo.Value = ""
.TxtTM.Value = ""
.TxtHUMNo.Value = ""
.TxtHUM.Value = ""
.TxtDismantle.Value = ""
.TxtTransport.Value = ""
.TxtSCS.Value = ""
.TxtSundry.Value = ""
.TxtSupplyBeams.Value = ""
.TxtOthers.Value = ""
.TxtENG.Value = ""
.TxtHire.Value = ""
.TxtHireWeeks.Value = ""
.TxtOH.Value = ""
.TxtWklyHire.Value = ""
.TxtTotal.Value = ""

'.TxtErect = Format(Erect, "$#,##0.00")

.lstdatabase.ColumnCount = 34
.lstdatabase.ColumnHeads = True

.lstdatabase.ColumnWidths = "50,20,60,60,20,100,120,120,20,20,20,80,80,80,80,80,80,80,20,80,20,80,80,80,80,80,80,80,80,80,20,80,80,80"

If iRow > 1 Then

.lstdatabase.RowSource = "Database!A2:AH" & iRow
Else

.lstdatabase.RowSource = "Database!A2:AH2"

End If



    End With



End Sub
Sub Submit()

    Dim sh As Worksheet
Dim iRow As Long


Set sh = ThisWorkbook.Sheets("Database")

If frmForm.TxtRowNumber.Value = "" Then

iRow = [Counta(Database!A:A)] + 1
Else

iRow = frmForm.TxtRowNumber.Value

End If



With sh


.Cells(iRow, 1) = frmForm.TxtDate.Value = Format(frmForm.TxtDate, Date, "mm/dd/yyyy")
.Cells(iRow, 2) = frmForm.TxtNo.Value
.Cells(iRow, 3) = frmForm.CmbConVar.Value
.Cells(iRow, 4) = frmForm.TxtQuoteNo.Value
.Cells(iRow, 5) = frmForm.TxtItemNo.Value
.Cells(iRow, 6) = frmForm.TxtArea.Value
.Cells(iRow, 7) = frmForm.TxtDes1.Value
.Cells(iRow, 8) = frmForm.TxtDes2.Value
.Cells(iRow, 9) = frmForm.TxtHeight.Value
.Cells(iRow, 10) = frmForm.TxtLength.Value
.Cells(iRow, 11) = frmForm.TxtLevels.Value
.Cells(iRow, 12) = frmForm.TxtErect.Value
.Cells(iRow, 13) = frmForm.TxtHUI1.Value
.Cells(iRow, 14) = frmForm.TxtHUI2.Value
.Cells(iRow, 15) = frmForm.TxtHUI3.Value
.Cells(iRow, 16) = frmForm.TxtSTD.Value
.Cells(iRow, 17) = frmForm.TxtLCS.Value
.Cells(iRow, 18) = frmForm.TxtIB.Value
.Cells(iRow, 19) = frmForm.txtTMNo.Value
.Cells(iRow, 20) = frmForm.TxtTM.Value
.Cells(iRow, 21) = frmForm.TxtHUMNo.Value
.Cells(iRow, 22) = frmForm.TxtHUM.Value
.Cells(iRow, 23) = frmForm.TxtDismantle.Value
.Cells(iRow, 24) = frmForm.TxtTransport.Value
.Cells(iRow, 25) = frmForm.TxtSCS.Value
.Cells(iRow, 26) = frmForm.TxtSundry.Value
.Cells(iRow, 27) = frmForm.TxtSupplyBeams.Value
.Cells(iRow, 28) = frmForm.TxtOthers.Value
.Cells(iRow, 29) = frmForm.TxtENG.Value
.Cells(iRow, 30) = frmForm.TxtHire.Value
.Cells(iRow, 31) = frmForm.TxtHireWeeks.Value
.Cells(iRow, 32) = frmForm.TxtOH.Value
.Cells(iRow, 33) = frmForm.TxtWklyHire.Value
.Cells(iRow, 34) = frmForm.TxtTotal.Value
.Cells(iRow, 35) = Application.UserName
.Cells(iRow, 36) = [text(Now(),"DD-MM-YY HH:MM:SS")]


    End With


End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,216,574
Messages
6,131,492
Members
449,653
Latest member
aurelius33

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