Display cell A2 and B1 and contents in message box

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
430
Office Version
  1. 365
Platform
  1. Windows
Hi i have the follwing code, which displays the contents of A2 in alert message box. is there any way to display the content of A2 and B1 in the same message box ?

Private Sub Worksheet_Calculate()
Dim myRange As Range
Set myRange = ActiveSheet.Range("F2:F2")
Dim cell As Range
For Each cell In myRange
Evaluate (cell)
If StrComp(cell, "Yes", vbTextCompare) = 0 Then
MsgBox Sheet1.Range("A2")
End If
Next
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

kanadaaa

Active Member
Joined
Dec 29, 2019
Messages
348
Office Version
  1. 365
Platform
  1. Windows
Add this below Public Sub
VBA Code:
Dim msg as Long
And change the line containing MsgBox to:
VBA Code:
msg = MsgBox("A2: " & Range("A2").Value & vbCrLf & "B1: " & Range("B1").Value, vbExclamation)
 

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
430
Office Version
  1. 365
Platform
  1. Windows
hi is there any way to change for code for 5 sheets ?
 

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
430
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

with using 5 sheets
is there a way to show content in alert of sheet1.A2 and B1,
then use code on sheet to to show content in alert of sheet2.A2 and B1,
 

kanadaaa

Active Member
Joined
Dec 29, 2019
Messages
348
Office Version
  1. 365
Platform
  1. Windows
Just paste the same code in each sheet module.
 

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
430
Office Version
  1. 365
Platform
  1. Windows
Thanks but have tried that but alert shows all 5 sheets, so i get 5 pop up alerts.
I think it maybe becuase all 5 sheets are active.
 

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
430
Office Version
  1. 365
Platform
  1. Windows
Thanks alot for help, problem is solved, thanks again
 

Forum statistics

Threads
1,141,068
Messages
5,704,093
Members
421,327
Latest member
Msh

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
Top