Return Cell References

C

Craig

I have a staff holiday worksheet showing months across and days (numbered 1
to 31) vertical. As the input box moves I want another cell reference to
show the month name and date ie. if cursor cell ref= b21 then another cell
would display February 21th. I need this to change in real time
irrespective of the data held in the cell actioned.
 
J

Jason Morin

With the months in B1:M1 and 1-31 in rows 2-32, right-
click the worksheet tab, select "View Code", and paste in
the code below:

Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)
Dim CurrMonth As Long
Dim CurrDay As Long
Dim CurrDate As Date
CurrMonth = ActiveCell.Column - 1
CurrDay = ActiveCell.Row - 1
CurrDate = DateSerial(2005, CurrMonth, CurrDay)
With Me.[A1]
If Month(CurrDate) <> CurrMonth Then
.Value = "Non-existent"
Else
.Value = CurrDate
End If
End With
End Sub

---

The first 2 lines are actually one line. The date should
appear in A1.

HTH
Jason
Atlnata, GA
 

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