Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tim tim is offline
external usenet poster
 
Posts: 105
Default formatting for feet and inches

I would like to format a cell automattically add the ' " to
a person height if the the data is only put in as 5 10.
Is there a way to format a cell for this.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default formatting for feet and inches

Hi Tim,

I found a way of doing it from a command button:

Private Sub CommandButton1_Click()
Dim feet, inches

feet = InputBox("Feet?")
inches = InputBox("Inches?")
Range("A1").Value = feet & "'" & " " & inches & "''"

End Sub

Hope that helps

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default formatting for feet and inches

Hi Tim,

I just wasn't happy with what I gave you so here's something more
solid. In the VBE go to worksheet one and pick Selection Change. Put
this code in:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.OnKey "~", "macro1"
Application.OnKey "{ENTER}", "macro1"
End Sub

Then create a macro called macro1 and Put this code into it:

Sub Macro1()
mystring = ActiveCell.Value
If Len(mystring) < 1 Then End
If InStr(mystring, " ") < 1 Then End
Position = InStr(mystring, " ")
newstring = Left(mystring, (Position - 1)) & """" & Right(mystring, 2)
& "'"
ActiveCell.Value = newstring
End Sub

Now go into your worksheet and put a value of format "number space
number" into any cell and press either enter key.
I assume all a user is going to do when they enter the value is either
press numeric enter or normal enter. Thats all this code allows for
(haven't figured the click event yet). If anyone knows how to improve
on this I would be most grateful!

Hope this is better for you Tim!


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default formatting for feet and inches

Joseph, that worked but I would like to limit to cell(AC14)
and the other problem will be that must of the input will
be by Tabbing in and out of the cells, I don't expect them
to be using the Enter key that much.
Is there a way to write it so that it formats upon exit
from that cell?
I had to change the order of [newstring = Left(mystring,
(Position - 1)) & """" & Right(mystring, 2)& "'"]
It was coming up 5" 10'

Thanks

-----Original Message-----
Hi Tim,

I just wasn't happy with what I gave you so here's

something more
solid. In the VBE go to worksheet one and pick Selection

Change. Put
this code in:

Private Sub Worksheet_SelectionChange(ByVal Target As

Excel.Range)
Application.OnKey "~", "macro1"
Application.OnKey "{ENTER}", "macro1"
End Sub

Then create a macro called macro1 and Put this code into

it:

Sub Macro1()
mystring = ActiveCell.Value
If Len(mystring) < 1 Then End
If InStr(mystring, " ") < 1 Then End
Position = InStr(mystring, " ")
newstring = Left(mystring, (Position - 1)) & """" & Right

(mystring, 2)
& "'"
ActiveCell.Value = newstring
End Sub

Now go into your worksheet and put a value of

format "number space
number" into any cell and press either enter key.
I assume all a user is going to do when they enter the

value is either
press numeric enter or normal enter. Thats all this code

allows for
(haven't figured the click event yet). If anyone knows

how to improve
on this I would be most grateful!

Hope this is better for you Tim!


---
Message posted from http://www.ExcelForum.com/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
feet inches multiply with feet inches okakavi About this forum 0 January 11th 11 05:20 PM
convert decimal inches into feet and inches Jason Stripling Excel Discussion (Misc queries) 2 April 23rd 09 02:45 PM
Convert inches & display as Feet Inches and Fractions -- BUG FREE Mark Main Excel Worksheet Functions 12 November 26th 08 08:50 PM
Custom formatting feet and inches from decimal adamaagard Excel Discussion (Misc queries) 0 May 6th 08 06:43 AM
Converting from feet, inches and fractions to inches and decimal p Dee Setting up and Configuration of Excel 5 September 18th 07 04:18 PM


All times are GMT +1. The time now is 09:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"