PC Review


Reply
Thread Tools Rate Thread

Add a button to each row of a spreadsheet

 
 
nacooke@gmail.com
Guest
Posts: n/a
 
      20th Dec 2006
Hi

I'm working on a spreadsheet that is dynamically populated from a
database query. I don't know how many rows will be returned by that
query.

What I would like to do is have a button at the beginning of each row
that will execute a function, passing in some of the values from the
the row.

Is this possible at all? I looked into adding a button using
ActiveSheet.OLEObjects.Add but this seems to have a maximum of 600
controls which is fewer than I may need. The excel form button is
quicker to use, but not sure if I can use it to execute my own code
with parameters rather than just a macro.

It doesn't have to be a button - just a way of executing code based on
the row the user is concerned with (e.g. could be double clicking on a
cell etc) I

Any tips or advice would be greatly appreciated.

Many thanks

Nick

 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      20th Dec 2006
Nick,
Your double-click idea will work.
It is not a good idea to put several hundred controls on a sheet.
Look in the sheet module. It has a double-click event that can
be used. Try code similar to the following...

Option Explicit
'Jim Cone - San Francisco, USA - December 2006
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Dim lngRow As Long
'Assumes user will double-click in column A.
If Not Application.Intersect(Target, Me.Columns(1)) Is Nothing Then
lngRow = Target.Row
'Row must have at least two cells with an entry and must be a row
'occurring below the header area.
If Application.CountA(Me.Rows(lngRow)) > 1 And lngRow > 3 Then
Call OtherSub(Target(1, 3).Value, Target(1, 4).Value, Target(1, 6).Value)
Cancel = True
End If
End If
End Sub
----------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


<(E-Mail Removed)>
wrote in message
Hi
I'm working on a spreadsheet that is dynamically populated from a
database query. I don't know how many rows will be returned by that
query.
What I would like to do is have a button at the beginning of each row
that will execute a function, passing in some of the values from the
the row.
Is this possible at all? I looked into adding a button using
ActiveSheet.OLEObjects.Add but this seems to have a maximum of 600
controls which is fewer than I may need. The excel form button is
quicker to use, but not sure if I can use it to execute my own code
with parameters rather than just a macro.
It doesn't have to be a button - just a way of executing code based on
the row the user is concerned with (e.g. could be double clicking on a
cell etc) I
Any tips or advice would be greatly appreciated.
Many thanks
Nick

 
Reply With Quote
 
 
 
 
Bob Flanagan
Guest
Posts: n/a
 
      20th Dec 2006
Add a menu item to the Tools menu that runs the code. The code can
determine the active cell. Or, it can display a confirmation box to confirm
the row or allow a row to be selected and then run.

Bob Flanagan
Macro Systems
144 Dewberry Drive
Hockessin, Delaware, U.S. 19707

Phone: 302-234-9857, cell 302-584-1771
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> I'm working on a spreadsheet that is dynamically populated from a
> database query. I don't know how many rows will be returned by that
> query.
>
> What I would like to do is have a button at the beginning of each row
> that will execute a function, passing in some of the values from the
> the row.
>
> Is this possible at all? I looked into adding a button using
> ActiveSheet.OLEObjects.Add but this seems to have a maximum of 600
> controls which is fewer than I may need. The excel form button is
> quicker to use, but not sure if I can use it to execute my own code
> with parameters rather than just a macro.
>
> It doesn't have to be a button - just a way of executing code based on
> the row the user is concerned with (e.g. could be double clicking on a
> cell etc) I
>
> Any tips or advice would be greatly appreciated.
>
> Many thanks
>
> Nick
>



 
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
Gridview: embedding a texbox and button in each row, passing info from that row to a function? Ken Fine Microsoft ASP .NET 4 14th Jul 2008 08:51 AM
Need to Add a Blank Row between every Row in a >400 Row Spreadsheet Mike Microsoft Excel Discussion 2 11th Apr 2007 03:10 AM
How to add a blank row after each existing row? =?Utf-8?B?U3RlcGhhbmll?= Microsoft Excel Misc 6 15th Nov 2006 05:11 AM
Add row and text between each row JR Microsoft Excel Programming 3 13th Apr 2006 11:00 PM
create TEXT files for EACH row in EACH xls Spreadsheet schiffkey Microsoft Excel Programming 0 21st Jan 2004 04:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:55 AM.