LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
hjc hjc is offline
external usenet poster
 
Posts: 17
Default named range in macro call

Is there a way to pass a named range (or even an unnamed block of cells) into
a macro?

I have written a macro that I want to use for several different ranges of
data. I have created multiple buttons that each call the macro, but I cannot
seem to find the right syntax to pass in the range of data that I want the
macro to use for each button. All I can do is to pass in the row and column
numbers that define the upper left and lower right corners of the data range,
as follows:

Private Sub CommandButton1_Click()
' Call Macro1(UpperLeftRow, UpperLeftCol, LowerRightRow, LowerRightCol)
Call Macro1(16, 9, 40, 35)
End Sub

Private Sub CommandButton2_Click()
Call Macro1(51, 9, 75, 35)
End Sub

etc.

If possible, I would like to be able to specify named ranges instead, so
that I don't have to edit the code for all the buttons if I add, delete or
move rows or columns. Is there a way to do this?

Thanks!
hjc

 
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
named range in macro call hjc Excel Programming 3 April 1st 10 08:59 PM
Named Range Macro Lost Excel Discussion (Misc queries) 1 September 22nd 09 11:17 PM
Trying to call a macro on selection of a cell in a range The Narcissist Excel Programming 2 September 26th 08 10:25 PM
Call Macro when Cell within Range Changes Andibevan[_2_] Excel Programming 4 March 24th 05 04:28 PM
Passing a range in a macro call Otto Moehrbach[_6_] Excel Programming 6 November 15th 04 02:31 PM


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