PC Review


Reply
Thread Tools Rate Thread

Determining the cell position of an object

 
 
=?Utf-8?B?Q2h1Y2sgSC4=?=
Guest
Posts: n/a
 
      5th Oct 2007
Help would be very appreciated, I am actually working on a worksheet where I
have a certain number of Toggle buttons on each row but on a unique column.
On column B, I have a numbering system reflecting a WBS (Work breakdown
structure number) and each time I click on a particular Toggle button of a
particular row number I would like the event to do the following:
Unhide let us say the next 3 rows and within these rows I would have a
document name, which I could click over and get the the document written in
word to open for Editing or viewing.
Now once the closing the word document, I may click the same Toggle button
to Hide those same unhidden rows.

Can anyone help me achieve such thing? I am new to VBA and unable to program
such event.

Thank you in advance for your comments and help!

Regards,
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      5th Oct 2007
If you use a togglebutton from the Control toolbox toolbar, you're going to need
a procedure for each of those buttons.

I'd use a button from the Forms toolbar and toggle the caption:

Then I could add as many buttons as I want and assign them to the same macro:

Option Explicit
Sub ClickButton()
Dim BTN As Button
Set BTN = ActiveSheet.Buttons(Application.Caller)

If LCase(BTN.Caption) = LCase("Hide Rows") Then
BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
BTN.Caption = "Show Rows"
Else
BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
BTN.Caption = "Hide Rows"
End If
End Sub

And you should be able to use a worksheet function:
=hyperlink("File:////yourpathtoyourword.doc","Click me!")

to start up your MSWord document.

Chuck H. wrote:
>
> Help would be very appreciated, I am actually working on a worksheet where I
> have a certain number of Toggle buttons on each row but on a unique column.
> On column B, I have a numbering system reflecting a WBS (Work breakdown
> structure number) and each time I click on a particular Toggle button of a
> particular row number I would like the event to do the following:
> Unhide let us say the next 3 rows and within these rows I would have a
> document name, which I could click over and get the the document written in
> word to open for Editing or viewing.
> Now once the closing the word document, I may click the same Toggle button
> to Hide those same unhidden rows.
>
> Can anyone help me achieve such thing? I am new to VBA and unable to program
> such event.
>
> Thank you in advance for your comments and help!
>
> Regards,


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?Q2h1Y2sgSC4=?=
Guest
Posts: n/a
 
      5th Oct 2007
Thanks Dave for your prompt and very efficient resolution! it works
perfectly. Just for curiosity, is there a way to change the button color the
way we can do for the Toggle or regular command button? and why is it that
the reaction using a command button or a toggle button one has to create as
manay procedures as they are buttons?

Thanks in advance!

Chuck

"Dave Peterson" wrote:

> If you use a togglebutton from the Control toolbox toolbar, you're going to need
> a procedure for each of those buttons.
>
> I'd use a button from the Forms toolbar and toggle the caption:
>
> Then I could add as many buttons as I want and assign them to the same macro:
>
> Option Explicit
> Sub ClickButton()
> Dim BTN As Button
> Set BTN = ActiveSheet.Buttons(Application.Caller)
>
> If LCase(BTN.Caption) = LCase("Hide Rows") Then
> BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
> BTN.Caption = "Show Rows"
> Else
> BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
> BTN.Caption = "Hide Rows"
> End If
> End Sub
>
> And you should be able to use a worksheet function:
> =hyperlink("File:////yourpathtoyourword.doc","Click me!")
>
> to start up your MSWord document.
>
> Chuck H. wrote:
> >
> > Help would be very appreciated, I am actually working on a worksheet where I
> > have a certain number of Toggle buttons on each row but on a unique column.
> > On column B, I have a numbering system reflecting a WBS (Work breakdown
> > structure number) and each time I click on a particular Toggle button of a
> > particular row number I would like the event to do the following:
> > Unhide let us say the next 3 rows and within these rows I would have a
> > document name, which I could click over and get the the document written in
> > word to open for Editing or viewing.
> > Now once the closing the word document, I may click the same Toggle button
> > to Hide those same unhidden rows.
> >
> > Can anyone help me achieve such thing? I am new to VBA and unable to program
> > such event.
> >
> > Thank you in advance for your comments and help!
> >
> > Regards,

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      5th Oct 2007
It's the difference between the controls on the Forms toolbar and the controls
on the Control toolbox toolbar.

With the Forms toolbar controls, you assign a macro. With the control toolbox
toolbar controls, you can double click on that control and see the event that
runs when you click it.

You can change the text on that button:
Option Explicit
Sub ClickButton()
Dim BTN As Button
Set BTN = ActiveSheet.Buttons(Application.Caller)

If LCase(BTN.Caption) = LCase("Hide Rows") Then
BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
BTN.Caption = "Show Rows"
BTN.Font.ColorIndex = 3
Else
BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
BTN.Caption = "Hide Rows"
BTN.Font.ColorIndex = 5
End If
End Sub

(Use colors that you can see!)

But you can use other shapes (from the drawing toolbar???) that you can make
prettier, too.



Chuck H. wrote:
>
> Thanks Dave for your prompt and very efficient resolution! it works
> perfectly. Just for curiosity, is there a way to change the button color the
> way we can do for the Toggle or regular command button? and why is it that
> the reaction using a command button or a toggle button one has to create as
> manay procedures as they are buttons?
>
> Thanks in advance!
>
> Chuck
>
> "Dave Peterson" wrote:
>
> > If you use a togglebutton from the Control toolbox toolbar, you're going to need
> > a procedure for each of those buttons.
> >
> > I'd use a button from the Forms toolbar and toggle the caption:
> >
> > Then I could add as many buttons as I want and assign them to the same macro:
> >
> > Option Explicit
> > Sub ClickButton()
> > Dim BTN As Button
> > Set BTN = ActiveSheet.Buttons(Application.Caller)
> >
> > If LCase(BTN.Caption) = LCase("Hide Rows") Then
> > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
> > BTN.Caption = "Show Rows"
> > Else
> > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
> > BTN.Caption = "Hide Rows"
> > End If
> > End Sub
> >
> > And you should be able to use a worksheet function:
> > =hyperlink("File:////yourpathtoyourword.doc","Click me!")
> >
> > to start up your MSWord document.
> >
> > Chuck H. wrote:
> > >
> > > Help would be very appreciated, I am actually working on a worksheet where I
> > > have a certain number of Toggle buttons on each row but on a unique column.
> > > On column B, I have a numbering system reflecting a WBS (Work breakdown
> > > structure number) and each time I click on a particular Toggle button of a
> > > particular row number I would like the event to do the following:
> > > Unhide let us say the next 3 rows and within these rows I would have a
> > > document name, which I could click over and get the the document written in
> > > word to open for Editing or viewing.
> > > Now once the closing the word document, I may click the same Toggle button
> > > to Hide those same unhidden rows.
> > >
> > > Can anyone help me achieve such thing? I am new to VBA and unable to program
> > > such event.
> > >
> > > Thank you in advance for your comments and help!
> > >
> > > Regards,

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?Q2h1Y2sgSC4=?=
Guest
Posts: n/a
 
      6th Oct 2007
Great! thank you and Happy thanksgiving!

Regards,

Chuck

"Dave Peterson" wrote:

> It's the difference between the controls on the Forms toolbar and the controls
> on the Control toolbox toolbar.
>
> With the Forms toolbar controls, you assign a macro. With the control toolbox
> toolbar controls, you can double click on that control and see the event that
> runs when you click it.
>
> You can change the text on that button:
> Option Explicit
> Sub ClickButton()
> Dim BTN As Button
> Set BTN = ActiveSheet.Buttons(Application.Caller)
>
> If LCase(BTN.Caption) = LCase("Hide Rows") Then
> BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
> BTN.Caption = "Show Rows"
> BTN.Font.ColorIndex = 3
> Else
> BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
> BTN.Caption = "Hide Rows"
> BTN.Font.ColorIndex = 5
> End If
> End Sub
>
> (Use colors that you can see!)
>
> But you can use other shapes (from the drawing toolbar???) that you can make
> prettier, too.
>
>
>
> Chuck H. wrote:
> >
> > Thanks Dave for your prompt and very efficient resolution! it works
> > perfectly. Just for curiosity, is there a way to change the button color the
> > way we can do for the Toggle or regular command button? and why is it that
> > the reaction using a command button or a toggle button one has to create as
> > manay procedures as they are buttons?
> >
> > Thanks in advance!
> >
> > Chuck
> >
> > "Dave Peterson" wrote:
> >
> > > If you use a togglebutton from the Control toolbox toolbar, you're going to need
> > > a procedure for each of those buttons.
> > >
> > > I'd use a button from the Forms toolbar and toggle the caption:
> > >
> > > Then I could add as many buttons as I want and assign them to the same macro:
> > >
> > > Option Explicit
> > > Sub ClickButton()
> > > Dim BTN As Button
> > > Set BTN = ActiveSheet.Buttons(Application.Caller)
> > >
> > > If LCase(BTN.Caption) = LCase("Hide Rows") Then
> > > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
> > > BTN.Caption = "Show Rows"
> > > Else
> > > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
> > > BTN.Caption = "Hide Rows"
> > > End If
> > > End Sub
> > >
> > > And you should be able to use a worksheet function:
> > > =hyperlink("File:////yourpathtoyourword.doc","Click me!")
> > >
> > > to start up your MSWord document.
> > >
> > > Chuck H. wrote:
> > > >
> > > > Help would be very appreciated, I am actually working on a worksheet where I
> > > > have a certain number of Toggle buttons on each row but on a unique column.
> > > > On column B, I have a numbering system reflecting a WBS (Work breakdown
> > > > structure number) and each time I click on a particular Toggle button of a
> > > > particular row number I would like the event to do the following:
> > > > Unhide let us say the next 3 rows and within these rows I would have a
> > > > document name, which I could click over and get the the document written in
> > > > word to open for Editing or viewing.
> > > > Now once the closing the word document, I may click the same Toggle button
> > > > to Hide those same unhidden rows.
> > > >
> > > > Can anyone help me achieve such thing? I am new to VBA and unable to program
> > > > such event.
> > > >
> > > > Thank you in advance for your comments and help!
> > > >
> > > > Regards,
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      6th Oct 2007
You're welcome.

And Happy Thanksgiving to you and your early frost celebrators!

Chuck H. wrote:
>
> Great! thank you and Happy thanksgiving!
>
> Regards,
>
> Chuck
>
> "Dave Peterson" wrote:
>
> > It's the difference between the controls on the Forms toolbar and the controls
> > on the Control toolbox toolbar.
> >
> > With the Forms toolbar controls, you assign a macro. With the control toolbox
> > toolbar controls, you can double click on that control and see the event that
> > runs when you click it.
> >
> > You can change the text on that button:
> > Option Explicit
> > Sub ClickButton()
> > Dim BTN As Button
> > Set BTN = ActiveSheet.Buttons(Application.Caller)
> >
> > If LCase(BTN.Caption) = LCase("Hide Rows") Then
> > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
> > BTN.Caption = "Show Rows"
> > BTN.Font.ColorIndex = 3
> > Else
> > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
> > BTN.Caption = "Hide Rows"
> > BTN.Font.ColorIndex = 5
> > End If
> > End Sub
> >
> > (Use colors that you can see!)
> >
> > But you can use other shapes (from the drawing toolbar???) that you can make
> > prettier, too.
> >
> >
> >
> > Chuck H. wrote:
> > >
> > > Thanks Dave for your prompt and very efficient resolution! it works
> > > perfectly. Just for curiosity, is there a way to change the button color the
> > > way we can do for the Toggle or regular command button? and why is it that
> > > the reaction using a command button or a toggle button one has to create as
> > > manay procedures as they are buttons?
> > >
> > > Thanks in advance!
> > >
> > > Chuck
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > If you use a togglebutton from the Control toolbox toolbar, you're going to need
> > > > a procedure for each of those buttons.
> > > >
> > > > I'd use a button from the Forms toolbar and toggle the caption:
> > > >
> > > > Then I could add as many buttons as I want and assign them to the same macro:
> > > >
> > > > Option Explicit
> > > > Sub ClickButton()
> > > > Dim BTN As Button
> > > > Set BTN = ActiveSheet.Buttons(Application.Caller)
> > > >
> > > > If LCase(BTN.Caption) = LCase("Hide Rows") Then
> > > > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = True
> > > > BTN.Caption = "Show Rows"
> > > > Else
> > > > BTN.TopLeftCell.Offset(1, 0).Resize(3, 1).EntireRow.Hidden = False
> > > > BTN.Caption = "Hide Rows"
> > > > End If
> > > > End Sub
> > > >
> > > > And you should be able to use a worksheet function:
> > > > =hyperlink("File:////yourpathtoyourword.doc","Click me!")
> > > >
> > > > to start up your MSWord document.
> > > >
> > > > Chuck H. wrote:
> > > > >
> > > > > Help would be very appreciated, I am actually working on a worksheet where I
> > > > > have a certain number of Toggle buttons on each row but on a unique column.
> > > > > On column B, I have a numbering system reflecting a WBS (Work breakdown
> > > > > structure number) and each time I click on a particular Toggle button of a
> > > > > particular row number I would like the event to do the following:
> > > > > Unhide let us say the next 3 rows and within these rows I would have a
> > > > > document name, which I could click over and get the the document written in
> > > > > word to open for Editing or viewing.
> > > > > Now once the closing the word document, I may click the same Toggle button
> > > > > to Hide those same unhidden rows.
> > > > >
> > > > > Can anyone help me achieve such thing? I am new to VBA and unable to program
> > > > > such event.
> > > > >
> > > > > Thank you in advance for your comments and help!
> > > > >
> > > > > Regards,
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining control’s position on a report Cheryl Microsoft Access Reports 2 17th Jul 2009 03:17 PM
Determining cursor position in a named range John Microsoft Excel Programming 3 6th Feb 2009 10:06 PM
Position drawing object relative to cell Horatio J. Bilge, Jr. Microsoft Excel Misc 2 29th Sep 2008 09:16 PM
Determining the Position of a Subreport clane Microsoft Access Reports 1 2nd Jul 2004 04:54 PM
Determining chart points at mouse position Steve Microsoft Excel Programming 2 30th May 2004 03:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:51 AM.