Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3
Default help with vba script

Here is PART of a script someone did for me

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , , 8)
For Each cell In myrar

When I run the script, and it does work well, I am prompted to put in the
RANGE for the script to look at before it proceeds. I would like to enter a
fixed area, such as A4:D12. How would I rewrite the ("What range",
rangetocheck, , , , , , 8) section to insert this fixed range?

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3
Default help with vba script

I guess I should have included the whole script. Just where should I put
what you suggested? And what should I leave out when I replace it??

Thanks again.

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , , 8)
For Each cell In myrar
Select Case cell.Value
Case Is = 90
colchoice = 4
Case Is = 80
colchoice = 6
Case Is = 70
colchoice = 40
Case Is = 60
colchoice = 3
Case Is < 60
colchoice = 2
End Select
cell.Interior.ColorIndex = colchoice
Next
End Sub





"Don Guillett" wrote in message
...

For Each cell In range("a2:a22")
cell.interior.ColorIndex=6
next cell

or simply
range("a2:a22").interior.ColorIndex=6


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"lariveesl" wrote in message
...
Here is PART of a script someone did for me

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , , 8)
For Each cell In myrar

When I run the script, and it does work well, I am prompted to put in the
RANGE for the script to look at before it proceeds. I would like to
enter a fixed area, such as A4:D12. How would I rewrite the ("What
range", rangetocheck, , , , , , 8) section to insert this fixed range?

Thanks




  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10,124
Default help with vba script

Not too hard to figure out.

Sub coloror()
For Each cell In range("a2:a22")
Select Case cell.Value
Case Is = 90:colchoice = 4
Case Is = 80:colchoice = 6
Case Is = 70:colchoice = 40
Case Is = 60:colchoice = 3
Case Is < 60:colchoice = 2
End Select
cell.Interior.ColorIndex = colchoice
Next
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"lariveesl" wrote in message
...
I guess I should have included the whole script. Just where should I put
what you suggested? And what should I leave out when I replace it??

Thanks again.

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , , 8)
For Each cell In myrar
Select Case cell.Value
Case Is = 90
colchoice = 4
Case Is = 80
colchoice = 6
Case Is = 70
colchoice = 40
Case Is = 60
colchoice = 3
Case Is < 60
colchoice = 2
End Select
cell.Interior.ColorIndex = colchoice
Next
End Sub





"Don Guillett" wrote in message
...

For Each cell In range("a2:a22")
cell.interior.ColorIndex=6
next cell

or simply
range("a2:a22").interior.ColorIndex=6


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"lariveesl" wrote in message
...
Here is PART of a script someone did for me

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , ,
8)
For Each cell In myrar

When I run the script, and it does work well, I am prompted to put in
the RANGE for the script to look at before it proceeds. I would like to
enter a fixed area, such as A4:D12. How would I rewrite the ("What
range", rangetocheck, , , , , , 8) section to insert this fixed range?

Thanks





  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,346
Default help with vba script

Hi,

A few minor changes (its good practice to declare your variables).

Sub coloror()
Dim cell As Range
Dim col As Integer
For Each cell In [a2:a22]
Select Case cell
Case Is = 90: col = 4
Case Is = 80: col = 6
Case Is = 70: col = 40
Case Is = 60: col = 3
Case Is < 60: col = 2
End Select
cell.Interior.ColorIndex = col
Next
End Sub
--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"lariveesl" wrote:

I guess I should have included the whole script. Just where should I put
what you suggested? And what should I leave out when I replace it??

Thanks again.

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , , 8)
For Each cell In myrar
Select Case cell.Value
Case Is = 90
colchoice = 4
Case Is = 80
colchoice = 6
Case Is = 70
colchoice = 40
Case Is = 60
colchoice = 3
Case Is < 60
colchoice = 2
End Select
cell.Interior.ColorIndex = colchoice
Next
End Sub





"Don Guillett" wrote in message
...

For Each cell In range("a2:a22")
cell.interior.ColorIndex=6
next cell

or simply
range("a2:a22").interior.ColorIndex=6


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"lariveesl" wrote in message
...
Here is PART of a script someone did for me

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , , 8)
For Each cell In myrar

When I run the script, and it does work well, I am prompted to put in the
RANGE for the script to look at before it proceeds. I would like to
enter a fixed area, such as A4:D12. How would I rewrite the ("What
range", rangetocheck, , , , , , 8) section to insert this fixed range?

Thanks







  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3
Default help with vba script

Thank you, both, for your help. Worked out great!


"Shane Devenshire" wrote in
message ...
Hi,

A few minor changes (its good practice to declare your variables).

Sub coloror()
Dim cell As Range
Dim col As Integer
For Each cell In [a2:a22]
Select Case cell
Case Is = 90: col = 4
Case Is = 80: col = 6
Case Is = 70: col = 40
Case Is = 60: col = 3
Case Is < 60: col = 2
End Select
cell.Interior.ColorIndex = col
Next
End Sub
--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"lariveesl" wrote:

I guess I should have included the whole script. Just where should I put
what you suggested? And what should I leave out when I replace it??

Thanks again.

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , , 8)
For Each cell In myrar
Select Case cell.Value
Case Is = 90
colchoice = 4
Case Is = 80
colchoice = 6
Case Is = 70
colchoice = 40
Case Is = 60
colchoice = 3
Case Is < 60
colchoice = 2
End Select
cell.Interior.ColorIndex = colchoice
Next
End Sub





"Don Guillett" wrote in message
...

For Each cell In range("a2:a22")
cell.interior.ColorIndex=6
next cell

or simply
range("a2:a22").interior.ColorIndex=6


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"lariveesl" wrote in message
...
Here is PART of a script someone did for me

Sub coloror()
Dim myrar As Range
Dim colchoice As Integer
Set myrar = Application.InputBox("What range", rangetocheck, , , , , ,
8)
For Each cell In myrar

When I run the script, and it does work well, I am prompted to put in
the
RANGE for the script to look at before it proceeds. I would like to
enter a fixed area, such as A4:D12. How would I rewrite the ("What
range", rangetocheck, , , , , , 8) section to insert this fixed range?

Thanks







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
Help with the script Angela[_2_] Excel Discussion (Misc queries) 1 March 22nd 08 10:36 PM
Help ! How do I do this in VB Script Sean Setting up and Configuration of Excel 3 March 17th 08 12:16 PM
help with the VB script Igneshwara reddy[_2_] Excel Worksheet Functions 4 March 6th 07 08:54 PM
I need some VB script please rlee1999 Excel Discussion (Misc queries) 2 October 25th 06 05:46 PM
VB script help - please!! Anthony Excel Discussion (Misc queries) 1 July 13th 05 01:19 AM


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

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

About Us

"It's about Microsoft Excel"