Message box

jaycee

Active Member
Joined
Jul 22, 2009
Messages
323
I have a loop that checks column L for values of greater than 9, this then adds a message box to say this, what I need is the value in the corresponding row column "B" value to show in the message box.

IE L11 is 12 then messsage box should have the value for B11
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Thanks for the quick reply, but where do I put it in the messagebox
I would like something like the following
Message
"You have selected more than 9 Months for (value column B) do you require this"
 
Upvote 0
What does the code look like right now?

If you want to use it in a messagebox, one route is to pass that value to a variable then display the variable as part of the text in the messagebox..
Something like this:
Text = ActiveCell.Offset(0, -10).Value
sure = MsgBox("You have selected more than 9 Months for " & Text & " do you require this", vbOKOnly, "Are you sure?")

(just made a quick edit to put the variable in the correct place!)
 
Last edited:
Upvote 0
Hi Slinky,
Thanks for that but I get error 1004 when trying

Below is my code
Code:
Sub Tour_Length()
Dim Text As String
 Dim r As Long
 Text = ActiveCell.Offset(0, -10).Value
    For r = Cells(Rows.Count, 12).End(xlUp).Row To 9 Step -1
        If Cells(r, 12).Value >= 9 Then MsgBox "You have stated that card Number " & vbNewLine & Text & "If this is correct then" & vbNewLine & "complete the extended tour form as well"
    Next r
End Sub
 
Upvote 0
I think I can see where the fault lies.

The cell in Column L is not beeing activated, I think therefore there is a fault with my loop?
 
Upvote 0
Try that...
Sub Tour_Length()
Dim Text As String
Dim r As Long
For r = Cells(Rows.Count, 12).End(xlUp).Row To 9 Step -1
If Cells(r, 12).Value >= 9 Then
MsgBox("You have stated that card Number " & vbNewLine & Cells(r,2).value & " If this is correct then" & vbNewLine & "complete the extended tour form as well", vbOKOnly, "Sure?")
Next r
End Sub

(note, untested!)
 
Upvote 0
Hi Slinky,

I did modify it slightly to the following
Code:
Sub Tour_Length()
Dim r As Long
For r = Cells(Rows.Count, 12).End(xlUp).Row To 9 Step -1
If Cells(r, 12).Value >= 9 Then MsgBox "You have stated that card Number " & vbNewLine & Cells(r, 2).Value & vbNewLine & " If this is correct then" & vbNewLine & "complete the extended tour form as well", vbOKOnly, "Sure?"
Next r
End Sub

The only problem I have now is that if I put this on the sheet to work after selection change, I get various errors as some of the cells are still blank and therefore cannot be used as data?
 
Upvote 0

Forum statistics

Threads
1,215,583
Messages
6,125,665
Members
449,247
Latest member
wingedshoes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top