Help needed with basic programming

  • Thread starter Thread starter londonal
  • Start date Start date
L

londonal

Hi there people. i have a few questions. help with any of them would b
greatly appreciated.

1. i have written the following macro to ask for level of income. i no
need to put Tax as 20% of income in cell D5. what do i do.

Sub income()
'
' income Macro
' Macro recorded 08/10/2004 by NEC Computers International
'
' Keyboard Shortcut: Ctrl+i
'
Range("D4").Select
ActiveCell.FormulaR1C1 = InputBox("income level?")

2. a macro contains two sub routines, master whbich declares the name
of the variables and asks for prices of 5 goods, and calacns whci
finds the demands for the five goods. How would you tell the sunrotin
Master to access the second subroutine calcns.

ANY help with that greatly appreicated. Ive been trying to tackle thes
to questions for ages and am getting nowehere.

Finally i need to addda button to run the tax macro again
 
Hi there people. i have a few questions. help with any of them would be
greatly appreciated.

1. i have written the following macro to ask for level of income. i now
need to put Tax as 20% of income in cell D5. what do i do.

Try this:

Sub income()
Dim incomeLevel As Single, temp As String
temp = InputBox("income level?")
If Not IsNumeric(temp) Then
MsgBox "You must enter a number!"
Exit Sub
End If
incomeLevel = Val(temp)
Cells(4, 4).Formula = incomeLevel
Cells(4, 5).Formula = incomeLevel * 0.2
End Sub
2. a macro contains two sub routines, master whbich declares the names
of the variables and asks for prices of 5 goods, and calacns whcih
finds the demands for the five goods. How would you tell the sunrotine
Master to access the second subroutine calcns.

At the point where you need it to run, just enter the name of the
subroutine:
sub master()
'...
'...
calcns
'...
'...
End Sub
ANY help with that greatly appreicated. Ive been trying to tackle these
to questions for ages and am getting nowehere.

Finally i need to addda button to run the tax macro again.

Where? On the sheet itself, or in the toolbar?

If on the sheet, bring up the control toolbox (View menu -> Toolbars ->
Control Toolbox), click on the command button, draw it where you want
it, then double-click to add code.

If on the toolbar (this is a one-time only solution, and not automatic)
bring up the customize dialog (View menu -> Toolbars -> Customize...),
select the Commands tab, scroll down to Macros on the left, and drag a
Command Button (on the right) to whatever toolbar you want it in, then
right-click the new button and select "Assign Macro..." to assign code
to it.
--
auric underscore underscore at hotmail dot com
*****
....hit enter and...
[THUNK - GRIND]
It's not supposed to do THAT.
[THUNK THUNK THUNK WHIRR GRIND GRIND]
 
For question 1, how about a worksheet function in D5?
=D4*0.2
Geof.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top