ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pasting a date to a cell from UserForm (https://www.excelbanter.com/excel-programming/431304-pasting-date-cell-userform.html)

Patrick C. Simonds

Pasting a date to a cell from UserForm
 
On my UserForm is a TextBox which gets populated during the UserForm
Initialization and it displays in the ddd dd mmm yy format (see first
set of code) this is so it is easier for the user when talking to the client
because they can refer to the day of the week. Some times they have to edit
the text entering the date as mm/dd/yy but when the value gets copied to the
cell a totally different date is displayed. Any thoughts?






TextBox7.Value = rng(1, 17) ' Date
of 1st Additional Contact Attempt
Me.TextBox7.Value = Format$(TextBox7.Value, "ddd dd mmm yy")




rng(1, 17) = Format(Mid(TextBox7.Value, 5), "mm/dd/yy") '1st Attemp Date
rng(1, 18).Value = TextBox6.Text '1st Attemp Time


FSt1

Pasting a date to a cell from UserForm
 
hi,
guessing here because i can't test. you have only posted bits and pieces of
your code.
but i think your problem is with the mid function.
you initialize the form with "ddd dd mmm yy" and the mid functions seems to
be moving that to the sheet as "mm/dd/yy". but the mid function seem
incomplete. should look like
''Format(Mid(TextBox7.Value, 5, 10), "mm/dd/yy")
but as said, i can't test.

i think your problem is here
Some times they have to edit the text entering the date as mm/dd/yy

this would throw the mid function as written off.

seem like you need a test of length on textbox1.

if LEN(me.textbox1.value)9 then
rng(1, 17) = Format(Mid(TextBox7.Value, 5), "mm/dd/yy")
else
rng(1, 17) =TextBox7.Value
end if

since i can't test, this is all a guess.
trying and see. post back if problems.
i'll be crashing soon so i may have to pick it up tomorrow.

regards
FSt1

"Patrick C. Simonds" wrote:

On my UserForm is a TextBox which gets populated during the UserForm
Initialization and it displays in the ddd dd mmm yy format (see first
set of code) this is so it is easier for the user when talking to the client
because they can refer to the day of the week. Some times they have to edit
the text entering the date as mm/dd/yy but when the value gets copied to the
cell a totally different date is displayed. Any thoughts?






TextBox7.Value = rng(1, 17) ' Date
of 1st Additional Contact Attempt
Me.TextBox7.Value = Format$(TextBox7.Value, "ddd dd mmm yy")




rng(1, 17) = Format(Mid(TextBox7.Value, 5), "mm/dd/yy") '1st Attemp Date
rng(1, 18).Value = TextBox6.Text '1st Attemp Time



FSt1

Pasting a date to a cell from UserForm
 
i screwed up
the if clause should look like this.

if LEN(me.textbox7.value)9 then
rng(1, 17) = Format(Mid(TextBox7.Value, 5), "mm/dd/yy")
else
rng(1, 17) =TextBox7.Value
end if


sorry. typo

regards
FSt1

"FSt1" wrote:

hi,
guessing here because i can't test. you have only posted bits and pieces of
your code.
but i think your problem is with the mid function.
you initialize the form with "ddd dd mmm yy" and the mid functions seems to
be moving that to the sheet as "mm/dd/yy". but the mid function seem
incomplete. should look like
''Format(Mid(TextBox7.Value, 5, 10), "mm/dd/yy")
but as said, i can't test.

i think your problem is here
Some times they have to edit the text entering the date as mm/dd/yy

this would throw the mid function as written off.

seem like you need a test of length on textbox1.

if LEN(me.textbox1.value)9 then
rng(1, 17) = Format(Mid(TextBox7.Value, 5), "mm/dd/yy")
else
rng(1, 17) =TextBox7.Value
end if

since i can't test, this is all a guess.
trying and see. post back if problems.
i'll be crashing soon so i may have to pick it up tomorrow.

regards
FSt1

"Patrick C. Simonds" wrote:

On my UserForm is a TextBox which gets populated during the UserForm
Initialization and it displays in the ddd dd mmm yy format (see first
set of code) this is so it is easier for the user when talking to the client
because they can refer to the day of the week. Some times they have to edit
the text entering the date as mm/dd/yy but when the value gets copied to the
cell a totally different date is displayed. Any thoughts?






TextBox7.Value = rng(1, 17) ' Date
of 1st Additional Contact Attempt
Me.TextBox7.Value = Format$(TextBox7.Value, "ddd dd mmm yy")




rng(1, 17) = Format(Mid(TextBox7.Value, 5), "mm/dd/yy") '1st Attemp Date
rng(1, 18).Value = TextBox6.Text '1st Attemp Time




All times are GMT +1. The time now is 05:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com