+ Reply to Thread
Results 1 to 3 of 3

Creating buttons using TopLeftCell

  1. #1
    Registered User
    Join Date
    01-22-2013
    Location
    tampa
    MS-Off Ver
    Excel 2010
    Posts
    2

    Creating buttons using TopLeftCell

    I have about 50 buttons to make, and I'd like to use the TopLeftCell property to determine the row I want to update so I don't have to make every button uniquely. I need to update columns B-E on each row after pressing a button asking for input.

    ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row (How do I use this properly?)

    Range("B2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value1", Default:=0))
    Range("C2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value2", Default:=0))
    Range("D2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value3", Default:=0))
    Range("E2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value4", Default:=0))

    Please help!
    Last edited by Ben F.; 01-22-2013 at 02:22 AM.

  2. #2
    Registered User
    Join Date
    01-22-2013
    Location
    tampa
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Creating buttons using TopLeftCell

    Quote Originally Posted by Ben F. View Post
    I have about 50 buttons to make, and I'd like to use the TopLeftCell property to determine the row I want to update so I don't have to make every button uniquely. I need to update columns B-E on each row after pressing a button asking for input.

    ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row (How do I use this properly?)

    Range("B2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value1", Default:=0))
    Range("C2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value2", Default:=0))
    Range("D2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value3", Default:=0))
    Range("E2").Select
    ActiveCell.Value = ActiveCell.Value + _
    Val(InputBox("Add value4", Default:=0))

    Please help!
    Figured it out for those looking for this is the future:

    ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    2).Value = ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    2).Value + _
    Val(InputBox("Add value1", Default:=0))

    ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    3).Value = ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    3).Value + _
    Val(InputBox("Add value2", Default:=0))

    ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    4).Value = ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    4).Value + _
    Val(InputBox("Add value3", Default:=0))

    ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    5).Value = ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Cells(1,
    5).Value + _
    Val(InputBox("Add value4", Default:=0))

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Creating buttons using TopLeftCell

    Which column are the buttons in?
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1