Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I make the formula see the message box answer?

I have a pop up message box as shown below

Dim Res As String
Res = InputBox("What is the cell address?")
If StrPtr(Res) = 0 Then
MsgBox "User Clicked Cancel"
ElseIf Res = vbNullString Then
MsgBox "User Clicked OK with no input"
Else
MsgBox "User Entered cell " & Res
End If
'
Now I need the answer to that reqeust to be in this formula where 0 is
the cell address that I have just entered. (This is a simple formual, but I
need to see if I can get it to work before I use it in a more complicated
formula)

ActiveCell.FormulaR1C1 = "=R[-1]C[2] + 0 "
Range("D7").Select
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I make the formula see the message box answer?

ActiveCell.FormulaR1C1 _
= "=R[-1]C[2] + " & range(res).address(referencestyle:=xlr1c1)

But I'd drop the inputbox and use application.inputbox.


Dim Rng as range

'...
Set rng = nothing
on error resume next
set rng = application.inputbox(Prompt:="Select a cell",type:=8).cells(1)
on error goto 0

if rng is nothing then
'user hit cancel
'what should happen?
else
ActiveCell.FormulaR1C1 _
= "=R[-1]C[2] + " & rng.address(referencestyle:=xlr1c1)
end if


Melody4572 wrote:

I have a pop up message box as shown below

Dim Res As String
Res = InputBox("What is the cell address?")
If StrPtr(Res) = 0 Then
MsgBox "User Clicked Cancel"
ElseIf Res = vbNullString Then
MsgBox "User Clicked OK with no input"
Else
MsgBox "User Entered cell " & Res
End If
'
Now I need the answer to that reqeust to be in this formula where 0 is
the cell address that I have just entered. (This is a simple formual, but I
need to see if I can get it to work before I use it in a more complicated
formula)

ActiveCell.FormulaR1C1 = "=R[-1]C[2] + 0 "
Range("D7").Select


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I make the formula see the message box answer?

Sub bBB()
res = InputBox("What is the cell address?")
If StrPtr(res) = 0 Then
MsgBox "User Clicked Cancel"
Exit Sub
ElseIf res = vbNullString Then
MsgBox "User Clicked OK with no input"
Exit Sub
Else
MsgBox "User Entered cell " & res
End If
ActiveCell.FormulaR1C1 = "=R[-1]C[2] +" & res
If ActiveCell.Text = "#NAME?" Then
res = Application.ConvertFormula(res, xlA1, xlR1C1)
ActiveCell.FormulaR1C1 = "=R[-1]C[2] +" & res
End If
End Sub

--
Regards,
Tom Ogilvy


"Melody4572" wrote in message
...
I have a pop up message box as shown below

Dim Res As String
Res = InputBox("What is the cell address?")
If StrPtr(Res) = 0 Then
MsgBox "User Clicked Cancel"
ElseIf Res = vbNullString Then
MsgBox "User Clicked OK with no input"
Else
MsgBox "User Entered cell " & Res
End If
'
Now I need the answer to that reqeust to be in this formula where 0 is
the cell address that I have just entered. (This is a simple formual, but
I
need to see if I can get it to work before I use it in a more complicated
formula)

ActiveCell.FormulaR1C1 = "=R[-1]C[2] + 0 "
Range("D7").Select



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I make the formula see the message box answer?

Perfect! Thanks Tom!

"Tom Ogilvy" wrote:

Sub bBB()
res = InputBox("What is the cell address?")
If StrPtr(res) = 0 Then
MsgBox "User Clicked Cancel"
Exit Sub
ElseIf res = vbNullString Then
MsgBox "User Clicked OK with no input"
Exit Sub
Else
MsgBox "User Entered cell " & res
End If
ActiveCell.FormulaR1C1 = "=R[-1]C[2] +" & res
If ActiveCell.Text = "#NAME?" Then
res = Application.ConvertFormula(res, xlA1, xlR1C1)
ActiveCell.FormulaR1C1 = "=R[-1]C[2] +" & res
End If
End Sub

--
Regards,
Tom Ogilvy


"Melody4572" wrote in message
...
I have a pop up message box as shown below

Dim Res As String
Res = InputBox("What is the cell address?")
If StrPtr(Res) = 0 Then
MsgBox "User Clicked Cancel"
ElseIf Res = vbNullString Then
MsgBox "User Clicked OK with no input"
Else
MsgBox "User Entered cell " & Res
End If
'
Now I need the answer to that reqeust to be in this formula where 0 is
the cell address that I have just entered. (This is a simple formual, but
I
need to see if I can get it to work before I use it in a more complicated
formula)

ActiveCell.FormulaR1C1 = "=R[-1]C[2] + 0 "
Range("D7").Select




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I make the formula see the message box answer?

Thank you to you also Dave. This one is somehting I can use in another
workbook.

"Melody4572" wrote:

Perfect! Thanks Tom!

"Tom Ogilvy" wrote:

Sub bBB()
res = InputBox("What is the cell address?")
If StrPtr(res) = 0 Then
MsgBox "User Clicked Cancel"
Exit Sub
ElseIf res = vbNullString Then
MsgBox "User Clicked OK with no input"
Exit Sub
Else
MsgBox "User Entered cell " & res
End If
ActiveCell.FormulaR1C1 = "=R[-1]C[2] +" & res
If ActiveCell.Text = "#NAME?" Then
res = Application.ConvertFormula(res, xlA1, xlR1C1)
ActiveCell.FormulaR1C1 = "=R[-1]C[2] +" & res
End If
End Sub

--
Regards,
Tom Ogilvy


"Melody4572" wrote in message
...
I have a pop up message box as shown below

Dim Res As String
Res = InputBox("What is the cell address?")
If StrPtr(Res) = 0 Then
MsgBox "User Clicked Cancel"
ElseIf Res = vbNullString Then
MsgBox "User Clicked OK with no input"
Else
MsgBox "User Entered cell " & Res
End If
'
Now I need the answer to that reqeust to be in this formula where 0 is
the cell address that I have just entered. (This is a simple formual, but
I
need to see if I can get it to work before I use it in a more complicated
formula)

ActiveCell.FormulaR1C1 = "=R[-1]C[2] + 0 "
Range("D7").Select




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
Auto answer message box csdjj Excel Discussion (Misc queries) 3 August 5th 09 06:33 PM
Answer an Outlook Express message box ozhunter Excel Worksheet Functions 1 May 22nd 09 02:35 PM
How can I repeat a macro, and how can make it without any message? emil Excel Programming 5 April 17th 06 09:31 PM
how do i add 2 columns to make the answer apper on the 3rd column merrymeet2u Excel Worksheet Functions 4 January 31st 06 03:59 PM
Code to make a New line in a message John Parham Excel Programming 2 September 18th 03 07:46 PM


All times are GMT +1. The time now is 07:52 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"