Holding Multiple Strings And Releasing Into Msgbox?

Lewzerrrr

Active Member
Joined
Jan 18, 2017
Messages
256
Hi all,

So I'm trying to set up a reminder that checks if the week number is the same as current week number, if so then display a msgbox containing the information but unsure of the method to store the information into a variable.

My code that I've started below is just a small scale but is along the lines of what I want however it doesn't contain multiple strings, just the last one in the loop.

Code:
Sub Reminder()

Dim wsSheet1 As Worksheet
Dim LR As Long, I As Long, X As Long


' Should I be using Arrays for this?
Dim AName() As Variant
Dim SNo() As Variant
Dim SName() As Variant
Dim MsgBody As String


Set wsSheet1 = Sheets(1)


LR = wsSheet1.Cells(Rows.Count, "A").End(xlUp).Row


    For I = 2 To LR
    
        With wsSheet1
            If .Cells(I, 1) = Evaluate("=weeknum(today()-238)") Then
                AName = .Cells(I, 2)
                SNo = .Cells(I, 3)
                SName = .Cells(I, 4)
            Else
            
            End If
        End With
    
    Next I
    
'How to use Arrays to contain multiple strings?
MsgBody = vbNewLine & vbNewLine & " - " & AName(X) & ": " & SNo(X) & " " & SName(X)


MsgBox "The following visit packs are needed this week:" & MsgBody


End Sub

Excel and what I want to display in the end..


ABCD
1WeekNoNameID NumberID Name
212Name1ID0001ID-Name1
312Name2ID0002ID-Name2
413Name3ID0003ID-Name3

<tbody>
</tbody>

Msgbox

Just a gentle reminder, the following are this week:

- Name1: ID0001 ID-Name1
- Name2: ID0002 ID-Name2
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Solved.

Code:
Sub Reminder2()

Dim ws As Worksheet
Dim r As Range, Rng As Range
Dim MsgBoxString As String


Set ws = Sheets(1)
Set Rng = ws.Range("A2:A" & ws.Cells(Rows.Count, "A").End(xlUp).Row)


    For Each r In Rng
        If r = Evaluate("=weeknum(today()-238)") Then
            MsgBoxString = MsgBoxString & r.Value & ": " & r.Offset(, 1).Value & " " & r.Offset(, 2).Value & " " & r.Offset(, 3) & vbNewLine
        Else
        
        End If
    Next r
    
    MsgBox "The following visit packs are required this week:" & vbNewLine & vbNewLine & MsgBoxString
    
Set ws = Nothing
Set Rng = Nothing


End Sub
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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