Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Relative positions from a button

Hi,
I have a button (currently a form button but could be changed) on a sheet
that adds 1 to a value elsewhere on the sheet. This setup is replaicted for
other rows.
the macro currently increments the value by using the offset method relative
to A1.
I would like to know if there is a way to do increment the value using the
relative position to the button either by assigning the button to a cell or
another way?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Relative positions from a button

Option Explicit
sub testme()
dim myBTN as button
set myBtn = activesheet.buttons(application.caller)

mybtn.topleftcell.offset(0,3).value = "hi there"
end sub

You can assign this kind of code to all the buttons (from the Forms toolbar).

Steve wrote:

Hi,
I have a button (currently a form button but could be changed) on a sheet
that adds 1 to a value elsewhere on the sheet. This setup is replaicted for
other rows.
the macro currently increments the value by using the offset method relative
to A1.
I would like to know if there is a way to do increment the value using the
relative position to the button either by assigning the button to a cell or
another way?

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Relative positions from a button

the button has both TopLeftCell and BottomRightCell properties.

You could use that

Sub Btn_click()
Dim btn as Button, rng as Range
set btn = Activesheet.Buttons(application.Caller)
set rng = btn.TopLeftCell
rng.offset(0,1).Value = rng.offset(0,1).Value + 1
End Sub

as an example, could be assigned to any such button designed to perform this
function.

--
Regards,
Tom Ogilvy


"Steve" wrote:

Hi,
I have a button (currently a form button but could be changed) on a sheet
that adds 1 to a value elsewhere on the sheet. This setup is replaicted for
other rows.
the macro currently increments the value by using the offset method relative
to A1.
I would like to know if there is a way to do increment the value using the
relative position to the button either by assigning the button to a cell or
another way?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Relative positions from a button

Thanks for your answer, this is perfect.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Relative positions from a button

Sorry - guess I misunderstood the explanation you gave when I offered my
suggestion. I thought you wanted to increment the cell when you really
wanted to enter "Hi there" in it. Is that correct?

--
Regards,
Tom Ogilvy


"Steve" wrote:

Thanks for your answer, this is perfect.

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
Lock Relative Cell Positions? cncf Excel Discussion (Misc queries) 0 June 3rd 08 05:17 PM
Copying charts and their data with relative cell positions Fodder937 Charts and Charting in Excel 0 August 25th 06 11:15 PM
How do I sum using relative cell positions? DavidB Excel Worksheet Functions 1 April 27th 05 03:44 AM
RELATIVE REFERENCE BUTTON Neil Mark Excel Discussion (Misc queries) 2 February 22nd 05 07:27 AM
Button - rearrange column positions in spreadsheet?possible No Name Excel Programming 5 December 30th 04 02:19 PM


All times are GMT +1. The time now is 09:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"