Can you advise replacement code for what now no longer works

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
6,002
Office Version
  1. 2024
Platform
  1. Windows
Below was the working code in use BUT My Datepicker doesnt work for 64 bit.

The line of code in RED is the issue.
Now on my userform i have TextBox12 with todays date but unable to see how i replace the line in RED for correct code


I select a custopmer in the listbox & run the code.
Its supposed to then add todays date on my userform.

I see the MsgBox advising its done but actually it isnt.


Rich (BB code):
        Private Sub DateTransferButton_Click()
        'Dantes code
            Dim sh As Worksheet
            Dim b As Range
            Dim wName As String, res As Variant
           
            If ListBox2.ListIndex = -1 Then
                MsgBox "YOU DIDNT SELECT A CUSTOMERS NAME", vbCritical, "DELIVERY PARCEL DATE TRANSFER"
                Exit Sub
            End If
           
            wName = ListBox2.List(ListBox2.ListIndex)
            Set sh = Sheets("POSTAGE")
            Set b = sh.Columns("B").Find(wName, LookIn:=xlValues, LookAt:=xlWhole)
            If Not b Is Nothing Then
                If sh.Cells(b.Row, "G") <> "" And UCase(sh.Cells(b.Row, "G")) <> "POSTED" Then
                    MsgBox "DATE HAS BEEN ENTERED ALREADY !" & vbCrLf & "CLICK OK TO GO CHECK IT OUT", vbCritical, "Delivery Parcel Date Transfer"
                   
                    Unload PostageTransferSheet
                    Cells(b.Row, "G").Select
                Else
                   
                    'sh.Cells(b.Row, "G").Value = CDate(Datepicker1.Value)
                   
                    sh.Cells(b.Row, "G").Interior.Color = vbYellow
                    MsgBox "DATE APPLIED TO WORKSHEET FOR " & ListBox2.Value, vbInformation, "DELIVERY PARCEL DATE TRANSFER MESSAGE"
                    ListBox2.Clear
                    UserForm_Initialize
                   
                End If
            End If
            ListBox2 = ""
           
        End Sub
 
Just an update.
In my Listbox i see customers name.
I run the code as supplied above.

I have managed to remove dead line of code above for this supplied below.

Rich (BB code):
sh.Cells(b.Row, "G").Value = TextBox12.Value

The TextBox on my form shows date correctly 08/03/225 of which is dd/mm/yyyy

When the code runs & the date is placed in the sheet cell i see 03/08/2025 of which is mm/dd/yyyy

Did i use the wrong replacement code of do i now need to do something else.
Please advise
 
Upvote 0
Try:

VBA Code:
sh.Cells(b.Row, "G").Value = CDate(TextBox12.Value)

Remember to put column G with date format dd/mm/yyyy
 
Upvote 0
Solution

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