MsgBox help

J

James C.

Can someone help with a problem I am having? I have a button that I want to
click on that will tell the user what months of data are loaded. The months
are listed in individual cells on a hidden data page. My end goal is to have
the user click the button and then a message box appear that says, "The
following months of data have been loaded: Jan, Feb....etc")

Any ideas on how to do this?
 
O

Office_Novice

Private Sub CommandButton1_Click()
MsgBox Range("A1").Value & " Has Been Loaded", vbInformation, "TiTLE"

End Sub
 
S

Sandy Mann

Something like:

Sub CommandButton1_Click()
Dim EndData As Long
Dim x As Long
Dim Msg As String

With Sheets("Sheet2")
EndData = .Cells(Rows.Count, 1).End(xlUp).Row

For x = 1 To EndData
Msg = Msg & .Cells(x, 1).Value & ", "
Next x

Msg = Left(Msg, Len(Msg) - 2)

MsgBox _
"The following Months of data have been loaded:" _
& vbLf & vbLf & Msg

End With
End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(e-mail address removed)
Replace @mailinator.com with @tiscali.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top