Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Apply a macro to a pre-selected range of cells

I wish to create a macro and assign it to a button such
that it formats the range of cells that has been selected
immediately prior to clicking the button (in the same way
that the "," or "%" format buttons work. But each time I
record the macro, it refers to the cell that is
highlighted as Range.Select."A5" or Range.Select."C1:J14"
etc.

How can I just refer to which-ever range has been selected?

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Apply a macro to a pre-selected range of cells

Did you try something like:

Sub x()

Dim Rg As Range

Set Rg = Selection

'your code here

Set Rg = Nothing

End Su

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Apply a macro to a pre-selected range of cells

Tim,

Try something like

Selection.NumberFormat = "0%"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"tim knowles" wrote in message
...
I wish to create a macro and assign it to a button such
that it formats the range of cells that has been selected
immediately prior to clicking the button (in the same way
that the "," or "%" format buttons work. But each time I
record the macro, it refers to the cell that is
highlighted as Range.Select."A5" or Range.Select."C1:J14"
etc.

How can I just refer to which-ever range has been selected?

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
modify a macro to apply to a specific range of cells Dave F Excel Discussion (Misc queries) 2 April 25th 07 03:00 AM
How do i a apply range(autoformat) in non-adjacent cells? Brent from the Bahamas New Users to Excel 2 January 23rd 06 10:42 AM
How to apply rounding across a range of cells with other formulae Steve T Excel Worksheet Functions 1 October 20th 05 07:39 PM
How can I apply the ROUND function to a range of cells in a workbo Ellemarr Excel Discussion (Misc queries) 5 June 11th 05 01:09 AM
How to apply a function across a range of cells Paul Excel Programming 0 July 9th 03 10:42 PM


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