I have a sheet which has several different named arrays with different dates in them. I'm trying to write a macro to loop through an array (determined during the macro) and then show a message box with all the dates in it (on separate lines). There will likely be blank cells at the bottom of each array that I'd like to avoid including in the message box. The HolShowOut reference links to a cell in the sheet that has the Named Array name in it that I want to use as the range. (The named array can change, depending on other actions in the sheet)
I've borrowed code from a response on another website and modified it slightly. The issue appears to be the myCell entry at the start of the For Each loop. The debug shows it as equalling Nothing, and I get an 1004 error, Method 'Range' of Object_Worksheet failed. rng does show the correct named array (DeskBook)
I can't put a copy of the sheet up unfortunately, local permission don't allow it.
I've borrowed code from a response on another website and modified it slightly. The issue appears to be the myCell entry at the start of the For Each loop. The debug shows it as equalling Nothing, and I get an 1004 error, Method 'Range' of Object_Worksheet failed. rng does show the correct named array (DeskBook)
VBA Code:
Private Sub Worksheet_Calculate()
Dim myCell As Range
Dim rng As String
Dim Msgstring As String
Sheets("Background").Activate
rng = Sheets("Background").Range("HolShowOut").Value
For Each myCell In Range(rng)
If myCell.Value <> 0 Then
If Msgstring <> "" Then
Msgstring = Msgstring & vbCr & myCell.Value
End If
End If
Next myCell
End Sub
I can't put a copy of the sheet up unfortunately, local permission don't allow it.