I'm not sure you understood the concept behind the code I posted in my
response. You do not need to have the DatePicker control visibly visible in
order to set it. Here is what I had posted (minus the variable
declaration)...
With Me.MultiPage1
CurrentPage = .Value
.Value = 1 ' This is tab number (zero based) containing the DatePicker
DTPickerReviewDate.Value = Date
.Value = CurrentPage
End With
Let's say that Tab #0 (default name Page1) is visible... the first line of
code stores this in the CurrentPage variable. Now, even though the second
line of code changes the Value property to 1, which makes Tab #1 (default
name Page2) visible, VB will not show you that until the subroutine finishes
running... however, BEFORE the subroutine finishes, the code sets the Value
property back to the originally visible tab. The net result of this is the
display does NOT visibly change to the user... he/she sees a static looking
UserForm during the execution of the above code; but for the code's
purposes, the tab was made "visible" long enough so that the DatePicker's
value could be changed. Now, I see from your code that you have (at least)
two MultiPage controls. Believe it or not, the above trick can be played
with the visibility of the MultiPage control (housing the two DatePicker
controls) as well... you do not have to test the visibility as your posted
code does.
Okay, now to your code. You do not have to iterate each control on the
UserForm looking for your two DatePicker controls... you can address them
directly. Also, using the above discussion, you do not have to test for
visibility either. Okay, let's see if we can implement all of this and apply
it to your code. I believe you can *replace* the entire For..Next block of
code that you posted with this code (declare the CurrentPage variable as
Long and the MPVisibleState variable as Boolean)...
frm.MultiPage1.Value = 3
With frm.MultiPage2
MPVisibleState = .Visible
.Visible = True
CurrentPage = .Value
.Value = 0
DTPickerDate.Value = Cells(53, col).Value
.Value = 1
DTPickerTestDate.Value = Cells(61, col).Value
.Value = CurrentPage
.Visible = MPVisibleState
End With
I believe this code will run that same as what you posted and that the user
should not see any of the visibility manipulations that are taking place.