Variables and formating

keeegs

Board Regular
Joined
Sep 25, 2011
Messages
145
Hi All

At the moment I have a macro that prints out a label depending on the information that is on a userform

My problem is that I have a date and it needs to me in the format dd-mmm-yy

At the moment I set the value from the DTPicker to a variable I4

The position that the date appears on the label can very depending on the type of the label.

Is there a way to set the format on the variable I4 so it doesnt matter what cell it is in?

Currently I am using:
Code:
ActiveCell.Offset(4, 1).NumberFormat = "dd-mmm-yy"

after I have put the data to a cell.

Any suggestions?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

keeegs

Board Regular
Joined
Sep 25, 2011
Messages
145
The only problem is that the cell that the information is in changes.
So thats why I want the string to already be in the format dd-mmm-yy as the information is used multiple times depending on how many labels they want
 

Watch MrExcel Video

Forum statistics

Threads
1,129,804
Messages
5,638,450
Members
417,025
Latest member
MusterDuster

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
Top