PC Review


Reply
Thread Tools Rate Thread

Dim cells in a sheet as a range

 
 
Corey
Guest
Posts: n/a
 
      30th Jul 2008
I am using a Select Case statement, and instead of having many Case
statements to cover ALL cell senarios, how can i use a line to 'DIM" an
array of cells?

Rather than something like:

Case Is = Sheet4.range("A1")
' code 1

Case Is = Sheet4.range("C3")
' code 2
Case Is = Sheet4.range("H10")
' code 3 etc............

How can i use some thing like:
Dim sh as Sheet4
Dim rng as Range
Set rng = sh.Cells("A1,C3,H10,...........")

Case Select Sheet1.range("D2").value
Case sh.rng
' code to work for ALL rng senario's....
end Select


How can i Syntax this?


 
Reply With Quote
 
 
 
 
Corey
Guest
Posts: n/a
 
      30th Jul 2008
Or maybe use a Defined Range in a sheet of cells instead in the Case
Statement?

"Corey" <(E-Mail Removed)> wrote in message
news:OV$(E-Mail Removed)...
>I am using a Select Case statement, and instead of having many Case
>statements to cover ALL cell senarios, how can i use a line to 'DIM" an
>array of cells?
>
> Rather than something like:
>
> Case Is = Sheet4.range("A1")
> ' code 1
>
> Case Is = Sheet4.range("C3")
> ' code 2
> Case Is = Sheet4.range("H10")
> ' code 3 etc............
>
> How can i use some thing like:
> Dim sh as Sheet4
> Dim rng as Range
> Set rng = sh.Cells("A1,C3,H10,...........")
>
> Case Select Sheet1.range("D2").value
> Case sh.rng
> ' code to work for ALL rng senario's....
> end Select
>
>
> How can i Syntax this?
>



 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      30th Jul 2008
Select Case UserForm1.ComboBox2
Case Is = Range("WorkShopRates") ' <= = Named range
MsgBox "W/Shop"
Case Is = Range("SiteRates") ' <= = Named range
MsgBox "Site"
End Select

Works

I think thus far anyhow


Corey....
"Corey" <(E-Mail Removed)> wrote in message
news:OV$(E-Mail Removed)...
>I am using a Select Case statement, and instead of having many Case
>statements to cover ALL cell senarios, how can i use a line to 'DIM" an
>array of cells?
>
> Rather than something like:
>
> Case Is = Sheet4.range("A1")
> ' code 1
>
> Case Is = Sheet4.range("C3")
> ' code 2
> Case Is = Sheet4.range("H10")
> ' code 3 etc............
>
> How can i use some thing like:
> Dim sh as Sheet4
> Dim rng as Range
> Set rng = sh.Cells("A1,C3,H10,...........")
>
> Case Select Sheet1.range("D2").value
> Case sh.rng
> ' code to work for ALL rng senario's....
> end Select
>
>
> How can i Syntax this?
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      30th Jul 2008
Do you mean

Case Not Intersect(rng, Sheet1.range("D2").Value) Is NOthing

--
__________________________________
HTH

Bob

"Corey" <(E-Mail Removed)> wrote in message
news:OV$(E-Mail Removed)...
>I am using a Select Case statement, and instead of having many Case
>statements to cover ALL cell senarios, how can i use a line to 'DIM" an
>array of cells?
>
> Rather than something like:
>
> Case Is = Sheet4.range("A1")
> ' code 1
>
> Case Is = Sheet4.range("C3")
> ' code 2
> Case Is = Sheet4.range("H10")
> ' code 3 etc............
>
> How can i use some thing like:
> Dim sh as Sheet4
> Dim rng as Range
> Set rng = sh.Cells("A1,C3,H10,...........")
>
> Case Select Sheet1.range("D2").value
> Case sh.rng
> ' code to work for ALL rng senario's....
> end Select
>
>
> How can i Syntax this?
>



 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      30th Jul 2008
What you can do depends on how similar or different code1, code2, code3,
etc. are. Can you give us some insight into what you are doing here?

Rick


"Corey" <(E-Mail Removed)> wrote in message
news:OV$(E-Mail Removed)...
>I am using a Select Case statement, and instead of having many Case
>statements to cover ALL cell senarios, how can i use a line to 'DIM" an
>array of cells?
>
> Rather than something like:
>
> Case Is = Sheet4.range("A1")
> ' code 1
>
> Case Is = Sheet4.range("C3")
> ' code 2
> Case Is = Sheet4.range("H10")
> ' code 3 etc............
>
> How can i use some thing like:
> Dim sh as Sheet4
> Dim rng as Range
> Set rng = sh.Cells("A1,C3,H10,...........")
>
> Case Select Sheet1.range("D2").value
> Case sh.rng
> ' code to work for ALL rng senario's....
> end Select
>
>
> How can i Syntax this?
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy a range of cells from one sheet to another Revolvr Microsoft Excel Programming 4 7th Oct 2008 11:54 PM
Change range from cells to sheet? =?Utf-8?B?SkJX?= Microsoft Excel Worksheet Functions 1 7th Nov 2007 03:33 PM
Concatenating a range of cells from another sheet, possible? rtilghman@gmail.com Microsoft Excel Worksheet Functions 7 7th Mar 2007 04:37 AM
Smallest range on sheet containing non-blank cells? Ken Johnson Microsoft Excel Programming 4 3rd Oct 2005 09:48 AM
Automatically entering sheet names into a range of cells on one sheet u539771 Microsoft Excel Worksheet Functions 2 23rd Jun 2004 12:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:09 PM.