MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 9th, 2002, 09:34 AM   #1
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default


I have a userform with a textbox on it. The textbox takes it's data from a cell in the spreadsheet. This cell has a time format like this "hh:mm:ss" so a typical entry on the sheet looks like this "01:14:59". Thing is, when it comes through on the userform, it loses it's format and comes through as numbers weird, like 2.6666669696969 and stuff.

How can I get round this?
buntykins is offline   Reply With Quote
Old May 9th, 2002, 09:55 AM   #2
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default

Further to this, I have just realised something. The number it is bringing through is the number in the cell, but displayed differently. So for instance 00:24:15 is displayed as 24.158787987987098709879087 in the textbox. Basically I think I just need to change the format of the textbox to hh:mm:ss. Does anyone know how to do this?

Sorry for not noticing the above before, god I am so blonde!
buntykins is offline   Reply With Quote
Old May 9th, 2002, 09:57 AM   #3
Russell
New Member
 
Join Date: Mar 2002
Posts: 39
Default

Assuming the cell referenced is A1 then try:
Format(Range("a1"), "hh:mm:ss")
In your code

Russell
Russell is offline   Reply With Quote
Old May 9th, 2002, 09:58 AM   #4
Mr Nick
Board Regular
 
Join Date: Mar 2002
Location: Manchester, UK
Posts: 95
Default

Does the source cell need to be time formatted? If it is text formatted, this does not happen.
Mr Nick is offline   Reply With Quote
Old May 9th, 2002, 10:21 AM   #5
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

Quote:
On 2002-05-09 08:55, buntykins wrote:
Further to this, I have just realised something. The number it is bringing through is the number in the cell, but displayed differently. So for instance 00:24:15 is displayed as 24.158787987987098709879087 in the textbox. Basically I think I just need to change the format of the textbox to hh:mm:ss. Does anyone know how to do this?

Sorry for not noticing the above before, god I am so blonde!
What about something like:

Dim Tme As String

Tme = Range("a1").Value
TextBox1 = Format(Tme, "hh:mm")

One thing I MUST point out is that the 2.6666669696969 you mentioned is not 16:00.
if you format the cell as [h]:mm you will see that it 64:00.

Excel rounds the time to within a day.

i.e. 24:00 is 1 day but format the cell as h:mm and it will look like 0:00 and as general 1

so 2.6666669696969 is 2 Days and 0.6666669696969 of a day, or, 16 hours. so:

2 days 48 hrs + 16 hrs = 64:00 formated as [h]:mm.

I hope I didn't bore you there. if you want the true [h]:mm use:

Dim Tme As String

Tme = Range("a1").Value
TextBox1 = Format(Tme, "[h]:mm")

hope this helps.

P.S. 24.158787987987098709879087 is 579:48:00 hours and minutes or 3:48:00 removing the day part NOT 0:24:15. don't know where you got that No.




_________________
Share the wealth!!
Ian Mac

[ This Message was edited by: Ian Mac on 2002-05-09 09:22 ]
Ian Mac is offline   Reply With Quote
Old May 10th, 2002, 02:20 AM   #6
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default


Thanks for your help guys, sorry I didn't reply last night but I went home. That code you gave me is great, BUT it's not appearing correctly.

The cell that the textbox is refenced to is showing 00:00:02, but the textbox is showing an actual time, like 09:15. It should be showing an amount of time.

This is crazy, all I want it to do is show exactly what's in the cell. The cell is formatted to [hh]:mm:ss

Anyone got any ideas?

Janie
buntykins is offline   Reply With Quote
Old May 10th, 2002, 02:41 AM   #7
Russell
New Member
 
Join Date: Mar 2002
Posts: 39
Default

If you change the cell you are referencing does the text box change and if so how?

Russell
Russell is offline   Reply With Quote
Old May 10th, 2002, 02:55 AM   #8
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default


The cell changes all the time, but it always stays in the same format - hh:mm:ss

The userform textbox changes accordingly, but in the wrong format
buntykins is offline   Reply With Quote
Old May 10th, 2002, 03:05 AM   #9
Audiojoe
Board Regular
 
Join Date: Feb 2002
Location: Where the wild roses grow
Posts: 285
Default


Hey Bunty,

That code that Ian gave you, you did change the references in it correctly didn't you...

Audiojoe
Audiojoe is offline   Reply With Quote
Old May 10th, 2002, 03:12 AM   #10
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default

Oh sh#t! No I didn't!!!

Oh guys I am so sorry. I forgot to change the cell reference in it! Oh my God, how blonde can someone be!!! It works fine now

I am so sorry to have wasted your time

Thanks Joe, you're a little star

xxxxxxxxxxxxxx
buntykins is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:21 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes