+ Reply to Thread
Results 1 to 9 of 9

bringing up the data -> form... box via macro

  1. #1
    Registered User
    Join Date
    01-16-2007
    Posts
    17

    bringing up the data -> form... box via macro

    Hello

    I have a simple list of data running fine, everything is going well. I want to jazz things up a bit by having a button which my users can press to edit the data in the list via the form... box, where they will be able to edit fields and move on to the next record easily.

    I've tried recording a macro, but upon running it says

    Run-time error '1004': ShowDataForm method of Worksheet class failed

    Knowing nothing about VBA, I'm presuming I have to do this in some way other than simply recording clicking in the list, then clicking Data -> Form....

    Could someone just quickly give me a little macro that will bring up the Form... box without a hitch?

    Please let me know if you require anymore information... I'm new to all this... Cheers!

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening splodgecat

    This should work OK. As long as you activecell is somewhere within your main datatable, Excel shouldpick up the whole range OK.

    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    01-16-2007
    Posts
    17
    Many thanks for your reply dominicb.

    Unfortunately I've tried what you suggested and it still comes up with the same error. Am I missing something here? I've copied exactly what you wrote and completely replaced the code of the macro with your code. And I've reassigned the macro to the button just in case.

    Any ideas? Should I abandon the extravagance? It really would be a nice addition to my spreadsheet. Cheers for the help!

  4. #4
    Registered User
    Join Date
    01-16-2007
    Posts
    17
    Anyone? Please help if you can.

  5. #5
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Dominic's code should work (I also tested it). Prior to this code, is the proper sheet activated that has the data? I can actually replicate your error if a sheet is activated that does not have any data.

    By the way, if you are using a command button, the focus is on the button when you click on it, the focus is not on the sheet. So you would have to select a cell on the sheet prior to it working:

    Please Login or Register  to view this content.
    Last edited by jasoncw; 01-17-2007 at 04:58 PM.

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi splodgecat

    Can't imagine why it's not working. Just tried the code again and it's working fine. Try the example below - it's silly data but it makes a point. Just tried it on XL2K and XL2003 no probs.

    HTH

    DominicB
    Last edited by dominicb; 08-19-2008 at 04:29 AM.

  7. #7
    Registered User
    Join Date
    01-16-2007
    Posts
    17
    thanks for replying guys, especially as its such a trivial problem.

    It doesn't matter now, cos I can just put my data onto your table that you posted and then it all works. My macro is exactly the same as yours but it doesnt work, and I just don't know why. It's bizarre.

    It goes without saying that I'm a complete novice at this but I definitely want to learn and I've just bought a book to help me. So maybe in a few weeks I'll be able to work out what I'm doing differently, it's probably something very basic. Thanks again for your help!

    I'll probably ask another question shortly....I'm fiddling around with stuff.

  8. #8
    Registered User
    Join Date
    01-16-2007
    Posts
    17
    could this be the reason...

    does the table have to begin at cell A1? mine was offset slightly with the button positioned above the table. moving things around seems to have made the button now work. What the hell?

  9. #9
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Quote Originally Posted by splodgecat
    could this be the reason...

    does the table have to begin at cell A1? mine was offset slightly with the button positioned above the table. moving things around seems to have made the button now work. What the hell?
    Playing around with it a little, it looks like the upper-left corner of the table needs to be somewhere in the range of A1:B2, not sure why, though.

+ 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