How Do I Display a Range of Cells in A Message Box Using VBA?

  • Thread starter Thread starter Excel Nerd
  • Start date Start date
E

Excel Nerd

Greetings,

I would like to display a range of cells in a message box. The VB
code that I'm using is:

MsgBox ThisWorkbook.Sheets("Calculation ").Range("g9:h19").value

There is something wrong with the range because when I program th
message box to display cell "g9" there's no problem. When I program th
message box to display "g9:h19" there is a problem.

Please Help...
 
You need to add each cell's value one at a time

dim c as range
dim sTxt as string


For Each c In Range("g9:h19")
stxt = stxt & vblf & c.value
Next cell

msgbox stx
 
Thanks Mudraker,

The code I used is:

Dim c As Range
Dim sTxt As String

For Each c In ThisWorkbook.Sheets("Calculation ").Range("g5:h19")
sTxt = sTxt & vbLf & c.Value
Next c

MsgBox sTxt


It worked perfectly... Thanks Again :
 
Back
Top