PDA

View Full Version : Please help



Spaced69
09-13-2019, 01:37 PM
Hi guys...really need help
Done best i can on userform
But update button doesnt work as should and just noticed that when i enter dates on userform some save as wrong format in sheet ie i put date as 07/12/18 but in sheet it is now 12/07/18
Attached file
If you do fix issues please make comments explaing so i can learn

austenr
09-13-2019, 01:46 PM
are the cells you update formatted in UK or american format?

Spaced69
09-13-2019, 02:24 PM
Formatted cells to uk dd/mm/yyyy
On userform also enter as uk
On purchase date entered 07/12/18
But noticed on sheet the cell had it as 12/07/2018
So now i have to edit all the data ive put in so far....i thought the update button was working...as had to click the vbyes a few times...but now wen i click it...the vbyesno remains and i have to close excel and restart now

SamT
09-13-2019, 07:51 PM
Query: is that December 7 or July 12?

In Code, convert Purchase Date to MS Date format, (decimal number,) then place Date into cell.

Purchase Date is probably a String. Microsoft application Dates are stored as decimal numbers that Excel displays as Strings. Test this by formatting the date cells as numbers. Then, does the 12/07/2018 cell display as a number?


Note: CDate requires setting the Application's Locale setting to English(UK)

'verbose. international
Dim Dte as Double
Dte = Cdate(PurchaseDate)
Cell = Dte


OR


'not international
Cell = Format(CDate(PurchaseDate), "dd/mm/yyyy")

OR


'International. allows other formatting of Cell
Cell = CDate(PurchaseDate)

BTW, IMO, the best international format is "MMM dd, yyyy" to display the month name vs month number.

Spaced69
09-14-2019, 12:55 AM
Any help with the update button
As said when click the vbyes the box remains and i hsve to quit out of excel..mi think ive created a loop...i use and adapted code from web...my first attempt wasnt updating the data as it should
It does now but as said im stuck with vbyesno box on screen until i exit program

austenr
09-14-2019, 09:08 AM
To escape without the task manager put in a vbCancel button in your form.

Spaced69
09-14-2019, 09:43 AM
Will give that a gp
Prob messed up with the code on the update button
Did attach my file if anyone wants to look and see where i went wrong

Spaced69
09-15-2019, 04:03 PM
Anyone !!
Really need to sort this asap...got tons of data to input in nxt few days