#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default union range

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default union range

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
'<<========



---
Regards.
Norman


"Atishoo" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default union range

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??

"Norman Jones" wrote:

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
'<<========



---
Regards.
Norman


"Atishoo" wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default union range

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)

"Atishoo" wrote in message
...
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??

"Norman Jones" wrote:

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
'<<========



---
Regards.
Norman


"Atishoo" wrote in message
...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default union range

ahhh now it all makes sense! (well some of it does)

"Bob Phillips" wrote:

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)

"Atishoo" wrote in message
...
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??

"Norman Jones" wrote:

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
'<<========



---
Regards.
Norman


"Atishoo" wrote in message
...
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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default union range

Hi Atishoo,

You should always use the Option Explicit
statement at the top of your code modules
and always explicitly declare all variables.

See Chip Pearson's suggestions at:

Using Variables (Properly) In VBA
http://www.cpearson.com/excel/variables.htm





---
Regards.
Norman
"Atishoo" wrote in message
...
ahhh now it all makes sense! (well some of it does)

"Bob Phillips" wrote:

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)

"Atishoo" wrote in message
...
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??


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
using UNION via Automation = invalid range result!? Mark Burns Excel Programming 3 October 9th 07 09:52 AM
union range Curt Excel Discussion (Misc queries) 9 April 20th 07 02:32 PM
union range problem Walter Excel Programming 2 May 13th 06 12:28 AM
Union/Range/Cells KentÄ[_3_] Excel Programming 2 March 11th 05 11:14 AM
Union method for Range Object Chad Excel Programming 5 March 10th 05 08:02 PM


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"