Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How to Enter data and Function in same cell

Hello, I am not sure if this should go in programming, so I'm going
to put it in misc. It's for people who might have also had this type
of problem. I had trouble with this and couldn't find it anywhere,
luckily I had a teacher help me with it and it wasn't hard at all.
Here's what the problem was.

My boss, who owns a cabinetry factory, wanted to make a spreadsheet for
customers which they could find out about what the total price would be
for there order. So for the dimensions he wanted them to automatically
round up.

EX: say you typed 8.001, it would round to 9.

There is nothing in excel that does that, without have to use a
function. Well he wanted them to type it in that cell and then have it
change.

So here's how you can have a function in the same cell you need to
type data in. It involves a little bit of VBA.

-Open the excel workbook
-Alt+F11 (This brings open the VBA editor) or go to: Tools / Macro /
Visual Basic Editor
-With the VBA editor open, there will be the Project menu on the left,
and it will have the workbook, Microsoft Excel Objects, and then all
the worksheets.

**Note** All the worksheets should be showing at start, but if they are
not then Go to the Projects menu on the left, hit the minus ( - ) next
to the VBAProject(Workbookname), then hit the minus on the Microsoft
Excel Objects folder, it will then display all the worksheets in the
workbook

-Double Click on the worksheet you wish to edit.
-A window will popup in the work area.
-On the top of that window there are 2 drop-down menus which should
say: (General) and (Declerations)
-Click the one the says (General) and change it to Worksheet
-Now go the other drop-down to the right (I believe it should now
display SelectChange as default). Click on it and select Change.
**Note** there are other things that you can do with it but for the
example I'm giving, I'm going to be using Change, which will
perform the action after I enter data into the cell

In the work area of the window you should see code that looks like
this:


Private Sub Worksheet_Change(ByVal Target As Range)

End Sub




For my example I need to round up the numbers in column C and E, as
they are being enterd, to the next whole Number. So my code looks like
this:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 Or Target.Column = 5 Then
Target = WorksheetFunction.RoundUp(Target, 0)
End If

End Sub




-Target is the default variable for the active cell
-The if statement checks if the changes being made are in column 3
(aka: column C) or column 5 (aka: column E)
-if the user has entered data in either one of those columns then it
will perform the task inside which sets Target (aka: the cell the user
just entered data into) equal to the worksheet function Roundup. Then
the arguments needed for Roundup to function properly, which in the
case for RoundUp would be (number to round up, to which decimal place
- 0 being no decimal places)

I hope this was clear enough and not to confusing. This can be very
helpful if you need/want a function to take place in the same cell you
type data in. This is a way to get around being able to only type in a
function or data into a single cell. Well I hope this helps someone
out. I know that I searched all over the internet and couldn't find
anything.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default How to Enter data and Function in same cell

OR without worksheet functions

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column = 3 Or Target.Column = 5 Then
Target = Int(Target + 0.99999999)
'Target = WorksheetFunction.RoundUp(Target, 0)
End If
Application.EnableEvents = True
End Sub

--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello, I am not sure if this should go in programming, so I'm going
to put it in misc. It's for people who might have also had this type
of problem. I had trouble with this and couldn't find it anywhere,
luckily I had a teacher help me with it and it wasn't hard at all.
Here's what the problem was.

My boss, who owns a cabinetry factory, wanted to make a spreadsheet for
customers which they could find out about what the total price would be
for there order. So for the dimensions he wanted them to automatically
round up.

EX: say you typed 8.001, it would round to 9.

There is nothing in excel that does that, without have to use a
function. Well he wanted them to type it in that cell and then have it
change.

So here's how you can have a function in the same cell you need to
type data in. It involves a little bit of VBA.

-Open the excel workbook
-Alt+F11 (This brings open the VBA editor) or go to: Tools / Macro /
Visual Basic Editor
-With the VBA editor open, there will be the Project menu on the left,
and it will have the workbook, Microsoft Excel Objects, and then all
the worksheets.

**Note** All the worksheets should be showing at start, but if they are
not then Go to the Projects menu on the left, hit the minus ( - ) next
to the VBAProject(Workbookname), then hit the minus on the Microsoft
Excel Objects folder, it will then display all the worksheets in the
workbook

-Double Click on the worksheet you wish to edit.
-A window will popup in the work area.
-On the top of that window there are 2 drop-down menus which should
say: (General) and (Declerations)
-Click the one the says (General) and change it to Worksheet
-Now go the other drop-down to the right (I believe it should now
display SelectChange as default). Click on it and select Change.
**Note** there are other things that you can do with it but for the
example I'm giving, I'm going to be using Change, which will
perform the action after I enter data into the cell

In the work area of the window you should see code that looks like
this:


Private Sub Worksheet_Change(ByVal Target As Range)

End Sub




For my example I need to round up the numbers in column C and E, as
they are being enterd, to the next whole Number. So my code looks like
this:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 Or Target.Column = 5 Then
Target = WorksheetFunction.RoundUp(Target, 0)
End If

End Sub




-Target is the default variable for the active cell
-The if statement checks if the changes being made are in column 3
(aka: column C) or column 5 (aka: column E)
-if the user has entered data in either one of those columns then it
will perform the task inside which sets Target (aka: the cell the user
just entered data into) equal to the worksheet function Roundup. Then
the arguments needed for Roundup to function properly, which in the
case for RoundUp would be (number to round up, to which decimal place
- 0 being no decimal places)

I hope this was clear enough and not to confusing. This can be very
helpful if you need/want a function to take place in the same cell you
type data in. This is a way to get around being able to only type in a
function or data into a single cell. Well I hope this helps someone
out. I know that I searched all over the internet and couldn't find
anything.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default How to Enter data and Function in same cell

The company is rounding 8.0001 to 9, for costing?? Please give me their name
so I can avoid buying there. :D

" wrote:

Hello, I am not sure if this should go in programming, so I'm going
to put it in misc. It's for people who might have also had this type
of problem. I had trouble with this and couldn't find it anywhere,
luckily I had a teacher help me with it and it wasn't hard at all.
Here's what the problem was.

My boss, who owns a cabinetry factory, wanted to make a spreadsheet for
customers which they could find out about what the total price would be
for there order. So for the dimensions he wanted them to automatically
round up.

EX: say you typed 8.001, it would round to 9.

There is nothing in excel that does that, without have to use a
function. Well he wanted them to type it in that cell and then have it
change.

So here's how you can have a function in the same cell you need to
type data in. It involves a little bit of VBA.

-Open the excel workbook
-Alt+F11 (This brings open the VBA editor) or go to: Tools / Macro /
Visual Basic Editor
-With the VBA editor open, there will be the Project menu on the left,
and it will have the workbook, Microsoft Excel Objects, and then all
the worksheets.

**Note** All the worksheets should be showing at start, but if they are
not then Go to the Projects menu on the left, hit the minus ( - ) next
to the VBAProject(Workbookname), then hit the minus on the Microsoft
Excel Objects folder, it will then display all the worksheets in the
workbook

-Double Click on the worksheet you wish to edit.
-A window will popup in the work area.
-On the top of that window there are 2 drop-down menus which should
say: (General) and (Declerations)
-Click the one the says (General) and change it to Worksheet
-Now go the other drop-down to the right (I believe it should now
display SelectChange as default). Click on it and select Change.
**Note** there are other things that you can do with it but for the
example I'm giving, I'm going to be using Change, which will
perform the action after I enter data into the cell

In the work area of the window you should see code that looks like
this:


Private Sub Worksheet_Change(ByVal Target As Range)

End Sub




For my example I need to round up the numbers in column C and E, as
they are being enterd, to the next whole Number. So my code looks like
this:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 Or Target.Column = 5 Then
Target = WorksheetFunction.RoundUp(Target, 0)
End If

End Sub




-Target is the default variable for the active cell
-The if statement checks if the changes being made are in column 3
(aka: column C) or column 5 (aka: column E)
-if the user has entered data in either one of those columns then it
will perform the task inside which sets Target (aka: the cell the user
just entered data into) equal to the worksheet function Roundup. Then
the arguments needed for Roundup to function properly, which in the
case for RoundUp would be (number to round up, to which decimal place
- 0 being no decimal places)

I hope this was clear enough and not to confusing. This can be very
helpful if you need/want a function to take place in the same cell you
type data in. This is a way to get around being able to only type in a
function or data into a single cell. Well I hope this helps someone
out. I know that I searched all over the internet and couldn't find
anything.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How to Enter data and Function in same cell

@Ricter

HaHa, well it never really gets that low. It's for door lengths, so
they will usually enter a fraction such as 3/8. But he needed it
becuase he would otherwise lose like .20 a door, which can add up
pretty fast.

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
wrap text function causes data to disappear in cell (visually only DaveT Excel Discussion (Misc queries) 17 November 23rd 17 07:59 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 04:44 PM
How to use cell data as part of hyperlink function txlonghorn1989 Excel Worksheet Functions 0 June 21st 06 11:12 PM
Enter data and display function result in same cell ChrisR Excel Discussion (Misc queries) 1 June 21st 06 01:15 AM
numerical integration integreat Excel Discussion (Misc queries) 4 May 12th 06 03:40 AM


All times are GMT +1. The time now is 06:27 AM.

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

About Us

"It's about Microsoft Excel"