PC Review


Reply
Thread Tools Rate Thread

Buttons Recognizing Rows

 
 
S Cho
Guest
Posts: n/a
 
      12th Sep 2004
Hello, thanks in advance for your help.

Goal: I would like to have a button anchored on Row 10 on my
worksheet, running a macro that will copy values from one area, then
paste those values into cells on Row 10.

Problem 1: How do you get the button/macro to "recognize" that it's on
Row 10, and that the pasted values are then to be placed in the cells
on Row 10. I don't know how to make the button identify the row that
it's on, and how to make the button use that information.

Problem 2: The button/macro needs to be flexible enough to perform the
same function when another row is added above it e.g., I could insert
a new row, so that Row 10 becomes Row 11, and the button is smart
enough to recognize that it's now on Row 11 and can paste those values
into cells on Row 11.

Thanks again,

Steve
 
Reply With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      12th Sep 2004
this could be done with buttons from the forms toolbar

for the macro assigned to the button, application.Caller will return the
name of the button. You can then do

Sub Btn_Click()
Dim btn as Button, sName as String, rw as Long
sName = Application.Caller
set btn = Activesheet.Buttons(sName)
rw = btn.TopLeftCell
msgbox sname & " is above cell " & btn.TopLeftCell.Address(0,0) _
& " and is on row " & rw
End sub

--
Regards,
Tom Ogilvy



"S Cho" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello, thanks in advance for your help.
>
> Goal: I would like to have a button anchored on Row 10 on my
> worksheet, running a macro that will copy values from one area, then
> paste those values into cells on Row 10.
>
> Problem 1: How do you get the button/macro to "recognize" that it's on
> Row 10, and that the pasted values are then to be placed in the cells
> on Row 10. I don't know how to make the button identify the row that
> it's on, and how to make the button use that information.
>
> Problem 2: The button/macro needs to be flexible enough to perform the
> same function when another row is added above it e.g., I could insert
> a new row, so that Row 10 becomes Row 11, and the button is smart
> enough to recognize that it's now on Row 11 and can paste those values
> into cells on Row 11.
>
> Thanks again,
>
> Steve



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      12th Sep 2004
Just a typo:

I think Tom meant:
rw = btn.TopLeftCell.Row
instead of just:
rw = btn.TopLeftCell



Tom Ogilvy wrote:
>
> this could be done with buttons from the forms toolbar
>
> for the macro assigned to the button, application.Caller will return the
> name of the button. You can then do
>
> Sub Btn_Click()
> Dim btn as Button, sName as String, rw as Long
> sName = Application.Caller
> set btn = Activesheet.Buttons(sName)
> rw = btn.TopLeftCell
> msgbox sname & " is above cell " & btn.TopLeftCell.Address(0,0) _
> & " and is on row " & rw
> End sub
>
> --
> Regards,
> Tom Ogilvy
>
> "S Cho" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello, thanks in advance for your help.
> >
> > Goal: I would like to have a button anchored on Row 10 on my
> > worksheet, running a macro that will copy values from one area, then
> > paste those values into cells on Row 10.
> >
> > Problem 1: How do you get the button/macro to "recognize" that it's on
> > Row 10, and that the pasted values are then to be placed in the cells
> > on Row 10. I don't know how to make the button identify the row that
> > it's on, and how to make the button use that information.
> >
> > Problem 2: The button/macro needs to be flexible enough to perform the
> > same function when another row is added above it e.g., I could insert
> > a new row, so that Row 10 becomes Row 11, and the button is smart
> > enough to recognize that it's now on Row 11 and can paste those values
> > into cells on Row 11.
> >
> > Thanks again,
> >
> > Steve


--

Dave Peterson
(E-Mail Removed)
 
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
Excel 2003 - VBA - Recognizing buttons Craig Brandt Microsoft Excel Discussion 4 9th Jun 2008 05:26 PM
Recognizing sets of rows julia Microsoft Excel Misc 3 1st Apr 2008 04:31 PM
Buttons Recognizing Rows S Cho Microsoft Excel New Users 2 12th Sep 2004 05:15 PM
Buttons Recognizing Rows S Cho Microsoft Excel Misc 2 12th Sep 2004 05:15 PM
Buttons Recognizing Rows S Cho Microsoft Excel Programming 2 12th Sep 2004 05:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:50 PM.