Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Prompt for a range to apply code to

Hello everyone. I have a piece of code that colors the contents of a
cell if the contents are hard-coded. This code as currently written
applies to the nentire sheet. I would like to apply this code to only
a specific range of cells. This will be used by end users, so ideally
I'd like then to push a button, which will then prpomt the user via a
form of some sort to select the range of cells. Can you help? Thanks
so much in advance!! Here's what I have now:

Sub ColorCellsRange()
On Error Resume Next
Cells.SpecialCells(xlCellTypeConstants, 1).Font.ColorIndex = 5
End Sub

-Steph
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Prompt for a range to apply code to

Hi Steph

Sub Test()
Dim R As Range
On Error Resume Next
Set R = Application.InputBox _
(Prompt:="Select a range with your mouse", _
Default:=Selection.Address, _
Type:=8)
If R Is Nothing Then Exit Sub
R.SpecialCells(xlCellTypeConstants, 1).Font.ColorIndex = 5
End Sub

HTH. Best wishes Harald

"Steph" skrev i melding
om...
Hello everyone. I have a piece of code that colors the contents of a
cell if the contents are hard-coded. This code as currently written
applies to the nentire sheet. I would like to apply this code to only
a specific range of cells. This will be used by end users, so ideally
I'd like then to push a button, which will then prpomt the user via a
form of some sort to select the range of cells. Can you help? Thanks
so much in advance!! Here's what I have now:

Sub ColorCellsRange()
On Error Resume Next
Cells.SpecialCells(xlCellTypeConstants, 1).Font.ColorIndex = 5
End Sub

-Steph



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Prompt for a range to apply code to

Hi Steph

Try this one

Sub test()
Dim rng As Range
On Error Resume Next
Application.DisplayAlerts = False
Set rng = Application.InputBox("Select a range with the mouse", _
Type:=8)
Application.DisplayAlerts = True
On Error GoTo 0
If rng Is Nothing Then
MsgBox "You Press cancel"
Exit Sub
End If
On Error Resume Next
rng.SpecialCells(xlCellTypeConstants, 1).Font.ColorIndex = 5
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steph" wrote in message om...
Hello everyone. I have a piece of code that colors the contents of a
cell if the contents are hard-coded. This code as currently written
applies to the nentire sheet. I would like to apply this code to only
a specific range of cells. This will be used by end users, so ideally
I'd like then to push a button, which will then prpomt the user via a
form of some sort to select the range of cells. Can you help? Thanks
so much in advance!! Here's what I have now:

Sub ColorCellsRange()
On Error Resume Next
Cells.SpecialCells(xlCellTypeConstants, 1).Font.ColorIndex = 5
End Sub

-Steph



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
alter code to apply to range (links cells w/ row insertions) purplec0ws Excel Discussion (Misc queries) 1 November 10th 09 10:19 AM
Problem undstanding how to apply a code Brenda Excel Discussion (Misc queries) 4 October 21st 08 07:55 PM
code to prompt before activating changes mhmaid New Users to Excel 1 August 18th 05 02:05 AM
Apply more than one filter in macro/vb code Stepnen Excel Programming 1 February 19th 04 07:49 PM
Would like to apply the code to protect cell sakijung Excel Programming 0 January 14th 04 09:13 AM


All times are GMT +1. The time now is 04:44 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"