VB help required

  • Thread starter adeel via OfficeKB.com
  • Start date
A

adeel via OfficeKB.com

I have a work book with 30 sheets (dates), first sheet is manu sheet, i
insert a calender object & a button. i just want that i click any date on
calender then click button and the sheet of selected date should be open.....
may be some vb use....please help
 
S

Shane Devenshire

Hi,

Cute idea, never thought of that. OK, here goes:

1. Choose View, Toolbars, Control Toolbox
2. On the control toolbox click the More Controls button - the last button
3. Scroll the list and find the Calendar10 control (the number will depend
on the version of that happens to be installed on your computer), click the
control and then click in the spreadsheet.
4. Right-click the calendar and choose View Code
5. Modify the subroutine to read

Private Sub Calendar1_Click()
Dim myDay As String
myDay = Me.Calendar1.Day
Sheets(myDay).Select
End Sub

Now return to the spreadsheet and turn off Design Mode on the Control
Toolbox toolbar - the 1st tool

Now to make this work the sheets must be named 1, 2, 3, ...31 just numbers.
If you are using a different naming convention you will need to modify the
code.
 
A

adeel via OfficeKB.com

Thanks alot, it works....but in my work book there are month wise sheet eg.
(from 1st jun to 30th jun & from 1st july to 31st july) in first sheet i want
to add this calender and then i want if the month in this calender is June
and then i press 1 or 2 or 3.... it move to that sheet of june, similarly
when i change the month to July then press 1 or 2 or 3....it move to that
sheet of july.....
 

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