sparky2205
Well-known Member
- Joined
- Feb 6, 2013
- Messages
- 507
- Office Version
- 365
- 2016
- Platform
- Windows
Hi folks,
I have a macro that takes an entry from an inputbox and assigns it to variable a of type variant.
A problem arises when the entry in the inputbox is similar to a date. e.g. if the value from the inputbox is FEB02. This is not a date, it just happens to resemble a date.
When analysing the code, variable a has the value "FEB02" which is what I want. But when I assign this value to a cell it gets assigned as 02-Feb.
I've tried changing the data type to String, to no effect. But I would prefer to leave it as variant anyway as it causes other issues later if the type is string.
I've also tried using CStr(a) when assigning the value, to no effect.
This is my inputbox:
This is my value assignment:
Any ideas what I'm doing wrong?
Thanks.
I have a macro that takes an entry from an inputbox and assigns it to variable a of type variant.
A problem arises when the entry in the inputbox is similar to a date. e.g. if the value from the inputbox is FEB02. This is not a date, it just happens to resemble a date.
When analysing the code, variable a has the value "FEB02" which is what I want. But when I assign this value to a cell it gets assigned as 02-Feb.
I've tried changing the data type to String, to no effect. But I would prefer to leave it as variant anyway as it causes other issues later if the type is string.
I've also tried using CStr(a) when assigning the value, to no effect.
This is my inputbox:
Code:
a = Application.InputBox("Enter the new Vendor Number", , , , , , , 2)
This is my value assignment:
Code:
Selection.Value = a
Any ideas what I'm doing wrong?
Thanks.