Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Making command button code "more flexible"

jamison,

Will this work for you???

mycount = Range("e" & ActiveCell.Row) + 1
Range("e" & ActiveCell.Row) = mycount

John

Jamison wrote:

I have command buttons in one column, that when clicked
add 1 to the value in an adjacent column. As of now the
code is very specific, here is the code for the buttons in
cells A4 and A5:
__________________________________
Private Sub CommandButton1_Click()
mycount = Range("e4") + 1
Range("e4") = mycount
End Sub

Private Sub CommandButton2_Click()
mycount = Range("e5") + 1
Range("e5") = mycount
End Sub
____________________________________

I would like to make it more flexible so that it adds 1 to
the cell in column e that is in the same row, instead of
having to list the row #. For example, it should add 1 to
the cell e"samerow", instead if creating twenty different
pieces of code like "e6", one for "e7", etc.,

I hope this makes sense.

Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Making command button code "more flexible"

Yes, that worked great. Thanks!
-----Original Message-----
jamison,

Will this work for you???

mycount = Range("e" & ActiveCell.Row) + 1
Range("e" & ActiveCell.Row) = mycount

John

Jamison wrote:

I have command buttons in one column, that when clicked
add 1 to the value in an adjacent column. As of now

the
code is very specific, here is the code for the buttons

in
cells A4 and A5:
__________________________________
Private Sub CommandButton1_Click()
mycount = Range("e4") + 1
Range("e4") = mycount
End Sub

Private Sub CommandButton2_Click()
mycount = Range("e5") + 1
Range("e5") = mycount
End Sub
____________________________________

I would like to make it more flexible so that it adds 1

to
the cell in column e that is in the same row, instead of
having to list the row #. For example, it should add 1

to
the cell e"samerow", instead if creating twenty

different
pieces of code like "e6", one for "e7", etc.,

I hope this makes sense.

Thanks.


.

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
"ClearContents" command halts code Dave O Excel Discussion (Misc queries) 3 January 10th 08 03:39 PM
"Flexible" External Links Thomas Excel Worksheet Functions 3 December 29th 06 05:23 PM
Programming a "Save as..." command button within Excel DavidHawes Excel Discussion (Misc queries) 2 November 13th 06 02:48 PM
Making a "Filter" button or field Wayne Knazek Excel Discussion (Misc queries) 1 June 9th 06 08:16 PM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM


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