+ Reply to Thread
Results 1 to 10 of 10

Simple macro button to create data - Please help

  1. #1
    Registered User
    Join Date
    01-23-2014
    Location
    Moline, IL
    MS-Off Ver
    Excel 2010
    Posts
    7

    Simple macro button to create data - Please help

    Hello, I want to thank you in advance for reading this. I have a button on Sheet1 that I want, when clicked, to enter the value "1" in cell "B2" on Sheet4. Although simple, I can not seem to get this to work. Below is the code that I have tried:


    Sub P1()
    Worksheets("Sheet4").Cell("B2").Select
    With ActiveCell
    ActiveCell.Value = "1"
    End With
    End Sub


    I also have the correct Macro assigned ("FileName.xslm!Sheet1.P1") to the rectangle on "Sheet1."

    Your help is much appreciated, I imagine it is a quick fix. I have exhausted the little expertise that I have, trying different renditions of the same code and exhausting the internet. Thank you!

  2. #2
    Forum Contributor
    Join Date
    12-09-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    171

    Re: Simple macro button to create data - Please help

    Please Login or Register  to view this content.
    Last edited by satabp; 02-14-2014 at 01:45 PM. Reason: Change in code

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Simple macro button to create data - Please help

    Hi,

    Simply:


    Please Login or Register  to view this content.
    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Simple macro button to create data - Please help

    Hi brandonlbrewere

    There are many ways, your code probably does not work because "B2" is a range, not a cell (in VBA). Change the code to Worksheets("Sheet4").Range("B2").Select and all should be well (change in red).

    Cheers

  5. #5
    Registered User
    Join Date
    01-23-2014
    Location
    Moline, IL
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Simple macro button to create data - Please help

    Quote Originally Posted by XOR LX View Post
    Hi,

    Simply:


    Please Login or Register  to view this content.
    Regards
    This worked! Thank you everyone for your assistance, I choose this one due to simplicity. To complete the code I need a little more code. If I want to change the active cell to a cell 2 below the push button, is there an easy scroll feature that does this? Thanks

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Simple macro button to create data - Please help

    Not sure what you mean, sorry.

    You mean you want to be able to drag the object housing your button around the sheet and have the active cell change accordingly? Sounds like quite a strange request if you don't mind me saying so - what's the purpose?

    Regards

  7. #7
    Registered User
    Join Date
    01-23-2014
    Location
    Moline, IL
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Simple macro button to create data - Please help

    This is a questionnaire sort of form. The buttons responds to a yes or no to the respective questions. The reason why the scroll is important is that it is zoomed in to where only 2 rows can be seen at a time to increase font size for the visually impaired. So if the code would automatically scroll for them, down two cells, that would be very convenient as it brings the next question into view!

    I hope that clears it up,
    Brandon

  8. #8
    Forum Contributor
    Join Date
    12-09-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    171

    Re: Simple macro button to create data - Please help

    Hi,

    you can add the following code for that, here 2 is the number rows you want to scroll

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-23-2014
    Location
    Moline, IL
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Simple macro button to create data - Please help

    Thank you! That code works perfectly, thanks again guys! I sincerely appreciate your help.

    Have a good day,

    Brandon

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Simple macro button to create data - Please help

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-03-2013, 06:38 AM
  2. Simple Open Macro Button
    By richard05 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2009, 07:34 AM
  3. A macro to create a form button, assign a macro and name the button
    By cl361 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2008, 01:07 AM
  4. Help with simple macro button
    By IowaTracy in forum Excel General
    Replies: 3
    Last Post: 08-27-2006, 01:56 PM

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