Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - Cell Reference for Active Button

I have a worksheet that contains several rows that need to be hidden /
unhidden via a macro attached to a button (from the Form toolbar).

I'd like to create one macro for all buttons. What I need to know is how to
reference the cell (or row) that the selected button is located in. I can
then hide the relevant rows below it.

Heres my code so far. It currently require the user to select a cell on the
row that the button is located.

Sub Button2_Click() 'HIDE
For i = 1 To 5
ActiveCell.Offset(i, 0).EntireRow.Hidden = True
Next i
End Sub

Thanks

Trevor
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default XL2002 - Cell Reference for Active Button

Hi Trvor,

Try something like:

'=============
Public Sub Tester()
Dim BTN As Button

Set BTN = ActiveSheet.Buttons(Application.Caller)
BTN.TopLeftCell.EntireRow.Hidden = True

End Sub
'<<=============


---
Regards,
Norman


"Trevor Williams" wrote in
message ...
I have a worksheet that contains several rows that need to be hidden /
unhidden via a macro attached to a button (from the Form toolbar).

I'd like to create one macro for all buttons. What I need to know is how
to
reference the cell (or row) that the selected button is located in. I can
then hide the relevant rows below it.

Heres my code so far. It currently require the user to select a cell on
the
row that the button is located.

Sub Button2_Click() 'HIDE
For i = 1 To 5
ActiveCell.Offset(i, 0).EntireRow.Hidden = True
Next i
End Sub

Thanks

Trevor



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - Cell Reference for Active Button

Hi Norman

Thanks, this is great. I also need to hide 5 rows below the current row but
don't have an Offset option with the TopLeftCell function. Is there a way to
hide the other rows?

Trevor


"Norman Jones" wrote:

Hi Trvor,

Try something like:

'=============
Public Sub Tester()
Dim BTN As Button

Set BTN = ActiveSheet.Buttons(Application.Caller)
BTN.TopLeftCell.EntireRow.Hidden = True

End Sub
'<<=============


---
Regards,
Norman


"Trevor Williams" wrote in
message ...
I have a worksheet that contains several rows that need to be hidden /
unhidden via a macro attached to a button (from the Form toolbar).

I'd like to create one macro for all buttons. What I need to know is how
to
reference the cell (or row) that the selected button is located in. I can
then hide the relevant rows below it.

Heres my code so far. It currently require the user to select a cell on
the
row that the button is located.

Sub Button2_Click() 'HIDE
For i = 1 To 5
ActiveCell.Offset(i, 0).EntireRow.Hidden = True
Next i
End Sub

Thanks

Trevor




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default XL2002 - Cell Reference for Active Button

Hi Trevor,

'-----------------
I also need to hide 5 rows below the current row but
don't have an Offset option with the TopLeftCell function. Is
there a way to hide the other rows?
'-----------------

Try:

'=============
Public Sub Tester()
Dim BTN As Button

Set BTN = ActiveSheet.Buttons(Application.Caller)
BTN.TopLeftCell.Resize(5).EntireRow.Hidden = True

End Sub
'<<=============


---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - Cell Reference for Active Button

Brilliant - thanks again Norman.

"Norman Jones" wrote:

Hi Trevor,

'-----------------
I also need to hide 5 rows below the current row but
don't have an Offset option with the TopLeftCell function. Is
there a way to hide the other rows?
'-----------------

Try:

'=============
Public Sub Tester()
Dim BTN As Button

Set BTN = ActiveSheet.Buttons(Application.Caller)
BTN.TopLeftCell.Resize(5).EntireRow.Hidden = True

End Sub
'<<=============


---
Regards,
Norman



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
using the active cell as a reference in a function JFA Excel Worksheet Functions 5 November 12th 08 01:43 AM
How to reference an active cell Tomá¹ Vognar New Users to Excel 5 March 14th 08 08:56 PM
XL2002: Button Labels & Sheets... Trevor Williams Excel Programming 2 April 13th 07 04:36 PM
Active row cell reference pskwaak Excel Worksheet Functions 2 March 18th 07 01:38 AM
Active Cell Reference pskwaak Excel Worksheet Functions 8 March 13th 07 02:22 AM


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