LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Selecting cells for code

One way:

Public Sub nseat()
Dim rSelect As Range
Set rSelect = Intersect(Selection, Range("C13:R10,D9:Q9"))
If Not rSelect Is Nothing Then
With rSelect.Interior
.ColorIndex = 41
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
rSelect.Value = "$2"
End If
End Sub



In article ,
Matt_16 wrote:

Right, I have this code that just tells the spreadsheet to turn the cell
blue, and put the value £2 in it:

Sub nseat()
'
' nseat Macro
' Macro recorded 14/11/2002 by Lambourn
'
' Keyboard Shortcut: Ctrl+n
'
With Selection.Interior
.ColorIndex = 41
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
ActiveCell.FormulaR1C1 = "$2 "
Range("K11").Select
End Sub

The problem is that this code can be used in any cell in the sheet,
whereas I would like to have it so that it can just be used in cells
C13-R10 and D9-Q9. How would I edit the code to enable me to do that?

Thanks


---
Message posted from http://www.ExcelForum.com/

 
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
Selecting Cells With Visual Basic or Macro Code RajenRajput1 Excel Discussion (Misc queries) 5 May 11th 07 05:56 PM
VBA Code for selecting worksheet Marie Bayes Excel Discussion (Misc queries) 5 January 11th 07 12:37 PM
VBA Code for selecting row [email protected] Excel Discussion (Misc queries) 2 June 9th 05 10:44 PM
Selecting a PivotItem in code Robert E. Peterson Excel Programming 1 February 4th 04 06:30 PM
VBA code for selecting and copying rows to another sheet. lothario[_6_] Excel Programming 4 October 14th 03 01:15 PM


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

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"