Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Programming a button

I have a button that I only want to be active if an adjacent cell on the left
is null AND the cell on the right is not null. So basically there are 8
buttons and I only want ONE to be active at a time, the LAST one that has
data in it. I have NEVER programmed VBA in Excel. I am proficient in VBA in
Access however. Once the button is active, I want it to copy all the values
of each cell into corresponding cells in another worksheet.

I truly appreciate any help you experts can provide.

Larry
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Programming a button

Right click on the worksheet tab and select view code.

Put in code like this which will fire each time the user selects a cell.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each oObject In Me.OLEObjects
If TypeOf oObject.Object Is MSForms.CommandButton Then
Set rng = oObject.TopLeftCell
If IsEmpty(rng.Offset(0, -1)) And IsEmpty(rng.Offset(0, 1)) Then
oObject.Object.Enabled = True
Else
oObject.Object.Enabled = False
End If
End If
Next
End Sub


this assumes commandbuttons from the control toolbox toolbar.

Your description is contradictory. You say you want the button enabled if
the cells are empty, but then you say you want the button enabled for the
last one with data.

You say when the button is made active, it should copy some data. You don't
want the user to click the button. If not, then why have buttons?

Perhas you can program Access with such vague descriptions, but excel
requires more definition as to where things are.

--
Regards,
Tom Ogilvy


"Larry G." wrote:

I have a button that I only want to be active if an adjacent cell on the left
is null AND the cell on the right is not null. So basically there are 8
buttons and I only want ONE to be active at a time, the LAST one that has
data in it. I have NEVER programmed VBA in Excel. I am proficient in VBA in
Access however. Once the button is active, I want it to copy all the values
of each cell into corresponding cells in another worksheet.

I truly appreciate any help you experts can provide.

Larry
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!

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
programming a button pappaz Excel Programming 2 February 26th 07 03:56 AM
programming button again Hendri Adriaens Excel Programming 5 February 14th 07 11:37 AM
programming button Mike Excel Programming 8 February 13th 07 10:51 PM
Control or VBA programming a button brianv Excel Programming 5 December 12th 03 02:26 PM
Programming behind a button DRE Excel Programming 2 July 18th 03 03:40 PM


All times are GMT +1. The time now is 08:47 PM.

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"