Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Put data in range of selected cells

I use a spreadsheet for duty rostas at work and have macros to enter codes
into a range of selected cells for various things like annual leave (H)
sickness (Y, S or F depending on certificate), maternity leave (M). I
currently merge the selected cells.

Here is an example of my macros.

Sub CodeM()
Application.Run "White"
Application.Run "CellsMerge"
ActiveCell.FormulaR1C1 = "M"
End Sub

Sub White()
ActiveCell.Font.Name = "Arial"
Selection.Font.FontStyle = "Bold"
Selection.Font.Size = 9
ColourCellWhite (0)
NoArrows (0)
End Sub

Sub CellsMerge()
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
End Sub

However, I don't really want the cells merged and would prefer the macro
'CodeM' (and other similar macros I have) to work through each highlighted
cell when the user clicks the button to run it and put the code in each one.

How do I get the macro to move through the selected cells, or put the same
code in all of them.

Many thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 373
Default Put data in range of selected cells

You could use something like this:

Sub SetEm()
Dim cell As Range
For Each cell In Selection
SetBold cell
Next cell
End Sub

Sub SetBold(c As Range)
With c
.Font.Bold = True
End With
End Sub

"MusicMaker" wrote in message
...
I use a spreadsheet for duty rostas at work and have macros to enter codes
into a range of selected cells for various things like annual leave (H)
sickness (Y, S or F depending on certificate), maternity leave (M). I
currently merge the selected cells.

Here is an example of my macros.

Sub CodeM()
Application.Run "White"
Application.Run "CellsMerge"
ActiveCell.FormulaR1C1 = "M"
End Sub

Sub White()
ActiveCell.Font.Name = "Arial"
Selection.Font.FontStyle = "Bold"
Selection.Font.Size = 9
ColourCellWhite (0)
NoArrows (0)
End Sub

Sub CellsMerge()
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
End Sub

However, I don't really want the cells merged and would prefer the macro
'CodeM' (and other similar macros I have) to work through each highlighted
cell when the user clicks the button to run it and put the code in each
one.

How do I get the macro to move through the selected cells, or put the same
code in all of them.

Many thanks.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Put data in range of selected cells

Thanks Zone. I adapted your code for my use and it worked a treat.

Many thanks.



"Zone" wrote:

You could use something like this:

Sub SetEm()
Dim cell As Range
For Each cell In Selection
SetBold cell
Next cell
End Sub

Sub SetBold(c As Range)
With c
.Font.Bold = True
End With
End Sub

"MusicMaker" wrote in message
...
I use a spreadsheet for duty rostas at work and have macros to enter codes
into a range of selected cells for various things like annual leave (H)
sickness (Y, S or F depending on certificate), maternity leave (M). I
currently merge the selected cells.

Here is an example of my macros.

Sub CodeM()
Application.Run "White"
Application.Run "CellsMerge"
ActiveCell.FormulaR1C1 = "M"
End Sub

Sub White()
ActiveCell.Font.Name = "Arial"
Selection.Font.FontStyle = "Bold"
Selection.Font.Size = 9
ColourCellWhite (0)
NoArrows (0)
End Sub

Sub CellsMerge()
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
End Sub

However, I don't really want the cells merged and would prefer the macro
'CodeM' (and other similar macros I have) to work through each highlighted
cell when the user clicks the button to run it and put the code in each
one.

How do I get the macro to move through the selected cells, or put the same
code in all of them.

Many thanks.




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 373
Default Put data in range of selected cells

You're welcome! Thanks for the feedback. James
"MusicMaker" wrote in message
...
Thanks Zone. I adapted your code for my use and it worked a treat.

Many thanks.



"Zone" wrote:

You could use something like this:

Sub SetEm()
Dim cell As Range
For Each cell In Selection
SetBold cell
Next cell
End Sub

Sub SetBold(c As Range)
With c
.Font.Bold = True
End With
End Sub

"MusicMaker" wrote in message
...
I use a spreadsheet for duty rostas at work and have macros to enter
codes
into a range of selected cells for various things like annual leave (H)
sickness (Y, S or F depending on certificate), maternity leave (M). I
currently merge the selected cells.

Here is an example of my macros.

Sub CodeM()
Application.Run "White"
Application.Run "CellsMerge"
ActiveCell.FormulaR1C1 = "M"
End Sub

Sub White()
ActiveCell.Font.Name = "Arial"
Selection.Font.FontStyle = "Bold"
Selection.Font.Size = 9
ColourCellWhite (0)
NoArrows (0)
End Sub

Sub CellsMerge()
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
End Sub

However, I don't really want the cells merged and would prefer the
macro
'CodeM' (and other similar macros I have) to work through each
highlighted
cell when the user clicks the button to run it and put the code in each
one.

How do I get the macro to move through the selected cells, or put the
same
code in all of them.

Many 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
Average Selected Cells From a Range pdberger Excel Worksheet Functions 3 July 19th 07 05:21 PM
data validation list selected from a range Native Excel Discussion (Misc queries) 11 January 20th 06 01:11 AM
How can i put a negative sign on a range of selected cells? chermaine Excel Discussion (Misc queries) 3 August 8th 05 02:49 AM
Automatically clear values from a range of selected cells John Davies Excel Discussion (Misc queries) 1 June 28th 05 04:42 PM
How do I merge in a selected range of cells out of Excel? powertots4 Excel Discussion (Misc queries) 1 December 28th 04 08:01 PM


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

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"