Msgbox to show two cell contents

SPLUCENA

Board Regular
Joined
Feb 24, 2009
Messages
189
Hi,

I am trying to assigned the values of two adjacent cell in a msgbox (columns AE and AF) as it is to far away for me to scroll and hiding the other columns will cause me to unhid it when I need to enter some information on it.
What I want to do, is when I double click activecell in column B, msgbox will pop and tell me the values nested in the same row under columns AE and AF (contract start date is : in column AE, contract end date : in column AF)

How to do this? I am trying this but it is giving me error. Kindly help....
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
MsgBox "Contract Start Date" & ActiveCell.Row.Offset(0, 30).Value & "Contract Start Date" & ActiveCell.Row.Offset(0, 31).Value

End Sub

Thanks!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 2 Then
    Cancel = True
    MsgBox "Contract Start Date" & vbTab & Format(Target.Offset(0, 29).Value, "dd/mm/yy") _
    & vbNewLine & "Contract End Date" & vbTab & Format(Target.Offset(0, 30).Value, "dd/mm/yy")
End If
End Sub
 
Upvote 0
Thanks Vog,

I have somehow managed to write this code too, but I prefer your code better:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
MsgBox "Contract Start Date :" & ActiveCell.Offset(0, 29).Value & vbNewLine & "Contract End Date :" & ActiveCell.Offset(0, 30) & vbNewLine & "Contract Value :" & ActiveCell.Offset(0, 31).Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,219,161
Messages
6,146,657
Members
450,706
Latest member
LGVBPP

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