Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 275
Default input box question/help

Is there a way using some code attached to my code given below that will
carry out this formula

=IF(P19="L",$S$6*$Z$1,IF(P19="W",($R$4*5)-$R$4,"0"))

in the cell directly under the cell the user input a value into

eg

The user inputs a number into cell P19, my input box will then be displayed
and I want the formula above calculated and the result placed into cell P20
as this is directly under cell P19!
my code thus far
Code:
Sub Input_box()
UserValue = InputBox("Unit Value?")
Cells(1, 26).Value = UserValue
End Sub

thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default input box question/help

Sub Input_box()
UserValue = InputBox("Unit Value?")
With Cells(1, 26)
.Value = UserValue
.Offset(1,0).Formula =
"=IF(P19=""L"",$S$6*$Z$1,IF(P19=""W"",($R$4*5)-$R$4,""0""))"
End With
End Sub



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Anthony" wrote in message
...
Is there a way using some code attached to my code given below that will
carry out this formula

=IF(P19="L",$S$6*$Z$1,IF(P19="W",($R$4*5)-$R$4,"0"))

in the cell directly under the cell the user input a value into

eg

The user inputs a number into cell P19, my input box will then be
displayed
and I want the formula above calculated and the result placed into cell
P20
as this is directly under cell P19!
my code thus far
Code:
Sub Input_box()
UserValue = InputBox("Unit Value?")
Cells(1, 26).Value = UserValue
End Sub

thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default input box question/help

Right click on the worksheet tab and select view code. In the resulting
module put in code like this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$P$19" Then
v = Evaluate("IF(P19=""L"",$S$6*$Z$1," & _
"IF(P19=""W"",($R$4*5)-$R$4,""0""))")
uservalue = InputBox("Value to be entered will be " & _
v)
Application.EnableEvents = False
Target.Offset(1, 0).Value = v
End If
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"Anthony" wrote:

Is there a way using some code attached to my code given below that will
carry out this formula

=IF(P19="L",$S$6*$Z$1,IF(P19="W",($R$4*5)-$R$4,"0"))

in the cell directly under the cell the user input a value into

eg

The user inputs a number into cell P19, my input box will then be displayed
and I want the formula above calculated and the result placed into cell P20
as this is directly under cell P19!
my code thus far
Code:
Sub Input_box()
UserValue = InputBox("Unit Value?")
Cells(1, 26).Value = UserValue
End Sub

thanks in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default input box question/help

If you actually want to prompt for a value by running a macro (not what you
described although what you described is confusing) then:

Sub Input_Box()
uservalue = InputBox("End single letter Choice: ")
Cells(19,"P").Value = UserValue

v = Evaluate("IF(P19=""L"",$S$6*$Z$1," & _
"IF(P19=""W"",($R$4*5)-$R$4,""0""))")
Application.EnableEvents = False
Cells(19,"P").Offset(1, 0).Value = v

End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote:

Right click on the worksheet tab and select view code. In the resulting
module put in code like this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$P$19" Then
v = Evaluate("IF(P19=""L"",$S$6*$Z$1," & _
"IF(P19=""W"",($R$4*5)-$R$4,""0""))")
uservalue = InputBox("Value to be entered will be " & _
v)
Application.EnableEvents = False
Target.Offset(1, 0).Value = v
End If
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"Anthony" wrote:

Is there a way using some code attached to my code given below that will
carry out this formula

=IF(P19="L",$S$6*$Z$1,IF(P19="W",($R$4*5)-$R$4,"0"))

in the cell directly under the cell the user input a value into

eg

The user inputs a number into cell P19, my input box will then be displayed
and I want the formula above calculated and the result placed into cell P20
as this is directly under cell P19!
my code thus far
Code:
Sub Input_box()
UserValue = InputBox("Unit Value?")
Cells(1, 26).Value = UserValue
End Sub

thanks in advance

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
Input Box Question bumper338 Excel Discussion (Misc queries) 4 March 20th 07 11:18 PM
Input Box Question StGermain Excel Discussion (Misc queries) 2 March 12th 07 05:14 PM
Input Box question No Name Excel Programming 1 January 8th 07 03:38 PM
Input Box Question with Code K Dales Excel Programming 0 August 16th 04 07:45 PM
Input box question losmac Excel Programming 0 August 20th 03 10:32 PM


All times are GMT +1. The time now is 02:51 AM.

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"