+ Reply to Thread
Results 1 to 5 of 5

Relative Macro Button Problems

Hybrid View

  1. #1
    Registered User
    Join Date
    10-09-2009
    Location
    Semmes
    MS-Off Ver
    Office 2007
    Posts
    2

    Question Relative Macro Button Problems

    I have Columns A Through E being used for a tower of data stacked by months.
    The idea is have a list broken up as so:
    January:......Name of Expense.......Owed
    --------this---is---my---button--------
    ...................Cable Bill..................$90
    ..................................Total:......$90
    February:.....Name of Expenses.....Owed
    --------the----second-----button------
    ...................Whatever.................$80
    ....................................Total:.....$80

    My button would add specific cells underneath it for more expenses to be entered. My macro worked great for the first one, BUT i have another button underneath it for February and when the rows are changed the macro for the other button is thrown off by 1 row. Somebody told me to do a relational Macro however I'm struggling to do that, it makes cells appear all over the place. I need help. Thanks
    Attached Images Attached Images

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Relative Macro Button Problems

    A copy of your file and existing procedures would be helpful. Including an after file (what you want it to look like) would be even more helpful. With this, I'd be glad to look at it. Please remove any proprietary information from your files if you choose to post.
    J
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    10-09-2009
    Location
    Semmes
    MS-Off Ver
    Office 2007
    Posts
    2

    Arrow Re: Relative Macro Button Problems

    Ok let me make this more clear to what i need help with. Basically im doing a relative reference in order to make a function triggered by the click of a button happen right under it no matter where the button is. Say its on the left side. Right under it will make a new row and merge specific cells. If i moved that button to the right side... it should do the same thing under it on the right. However when i create this type of macro the reference point is the cell selected. If im clicking a button to activate this any cell i have selected b4 will be affected, rather making it happen under it. I tried editing the code to make the button itself the reference point however im not sure how to do this. So my question is simple. How do I make the button i click the starting point of my macro? Not the cell. Because the cells change and the buttons don't.

    If thats not possible maybe a command to select the cell that is right under or behind the button thats being clicked would help.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Relative Macro Button Problems

    Sorry, don't understand your issue so I'm unable to help.
    J

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Relative Macro Button Problems

    Hello Jackel159,

    Welocme to the Forum!

    Create your buttons using the Forms Toolbar and attach this macro to each button.
    Sub AddRowBelow()
    
      Dim Btn As Excel.Button
    
        Set Btn = ActiveSheet.Buttons(Application.Caller)
          With Btn.TopLeftCell
            Btn.Left = .Left
            Btn.Top = .Top
            .EntireRow.Offset(1, 0).Insert
          End With
          
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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