union range

A

Atishoo

Im trying to get a callendar to appear whenever the active cell falls within
a series of large pre defined ranges reffered to as date1, date2 etc up to
date9
I keep getting error on this code i know im missing something really dumb
can anyone help?

With ActiveSheet.Calendar1
Set bigdaterange = Application.Union(Range("date1"), Range("date2"),
Range("date3"), Range("date4"), Range("date5"), Range("date6"),
Range("date7"), Range("date8"), Range("date9"))
If Not Intersect(Target, Range("bigdaterange")) Is Nothing Then
.Visible = True
.Top = Target.Top + Target.Cells.Height
.Left = Target.Left
Else
 
N

Norman Jones

Hi Atishoo,

BigDateRange is an object variable, not
a named range. so try removing the
surrounding quotes.

Try something like:

'========>>
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim BigDateRange As Range

With Me.Calendar1
Set BigDateRange = Application.Union( _
Range("date1"), _
Range("date2"), _
Range("date3"), _
Range("date4"), _
Range("date5"), _
Range("date6"), _
Range("date7"), _
Range("date8"), _
Range("date9"))
If Not Intersect(Target, BigDateRange) Is Nothing Then
.Visible = True
.Top = Target.Top + Target.Cells.Height
.Left = Target.Left
Else
.Visible = False
End If
End With

End Sub
'<<========
 
A

Atishoo

Oh yeees its so good when something works!!
thankyou very much that really hits the spot!!
works like a dream
thanks john
ps what does the command "Dim" actually stand for??
 
B

Bob Phillips

Dimension, it declares a variable, putting As ... declares the data type.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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