Change Microsoft Monthview position on excel sheet….

Jiurasic

Board Regular
Joined
Sep 22, 2007
Messages
86
I placed Monthview ActiveX control on excel Sheet. I want this control to be appeared when user click at any cell in column 4. To show this control in right position I wrote such code:

Code:
Private Sub Worksheet_SelectionChange(Byval Target as Range)

If Target.Column <> 4 Then
MonthView1.Visible = False
Exit Sub
End If

Monthview1.visible=true        ‘1
Monthview1.Left=Target.left
Monthview1.Top=Target.Top
Monthview1.visible=true	 ‘2


End Sub


An active is Row number 1 or 2.


If I place Monthview1.visible=true on the 1-st place is appears double such Montview controls….why? It is looks like Excel doesn’t Repaint th sheet. But if I put such row Monthview1.visible=true on the 2-st place everything is good but I saw the “transference” on this control……..and it is not a good view.



How can I do it right?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I am not familiar with monthlyviewcontrol in excel. I am doing visual basic 2008.

In excel 2002 the control is called "calendar control"

In the properties window of this control you see the name
and also make visible property as false
and go out of the design mode .
now run your event handler.

I am wondering whether the second visible =true is necessary.

you can do step by step debugging of event handler.
on the left of the first line of the code click. you get a brown filled circle
when you change your cell to any cell in column D the code will come up withthe first line in yellow. then you succesively hit F8 till you hit F8 on end sub. This will give you an idea of error if any.

all the above is sort of intelligent guess.
 
Last edited:
Upvote 0
I placed Monthview ActiveX control on excel Sheet. I want this control to be appeared when user click at any cell in column 4. To show this control in right position I wrote such code:

Code:
Private Sub Worksheet_SelectionChange(Byval Target as Range)

If Target.Column <> 4 Then
MonthView1.Visible = False
Exit Sub
End If

Monthview1.visible=true        ‘1
Monthview1.Left=Target.left
Monthview1.Top=Target.Top
Monthview1.visible=true     ‘2


End Sub


An active is Row number 1 or 2.


If I place Monthview1.visible=true on the 1-st place is appears double such Montview controls….why? It is looks like Excel doesn’t Repaint th sheet. But if I put such row Monthview1.visible=true on the 2-st place everything is good but I saw the “transference” on this control……..and it is not a good view.



How can I do it right?

simple...

just try activating any other sheet in the same excel workbook....and come back to the sheet where monthview1 resides...wooph your control will be in a place where you want.

through you do it same way

Suppose your Monthview1 is on "sheet1" of the workbook

Sub workbook.open()

With thisworkbook.worksheets("sheet1").monthview1
.left=450
.top=50
End with

Thisworkbook.worksheets("sheet1").activate
Thisworkbook.worksheets("sheet2").activate
Thisworkbook.worksheets("sheet1").activate

End sub
..
...
activating "Sheet1" twice solves your problem
I did it in windows 10(64bit) MS office 2016(32bit)
 
Upvote 0

Forum statistics

Threads
1,226,099
Messages
6,188,899
Members
453,510
Latest member
LarryWB423

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