+ Reply to Thread
Results 1 to 22 of 22

Comand in Makro not working

  1. #1
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Comand in Makro not working

    Hi

    I'm using this code:

    Please Login or Register  to view this content.
    To copy some stuff from one sheet to other and so it makes a hyperlink to it. Everything works fine exept I'm tryn to get the sheet.name in to cell "B2". And it's not working no matter what I do. Can anyone help please?
    Last edited by stojko89; 11-16-2011 at 06:52 AM.

  2. #2
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    After the table is copyed and the width of the colums is set I just want the B2 cell to have the same name as the sheet name.

    And it already says that
    Please Login or Register  to view this content.
    and I'm using
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    You have misspelt ColumnWidth so the code errors before setting the value of B2

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    LOL ok I didn't see that

    But I fixed that and tryed:

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    Still doesn't work

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Comand in Makro not working

    You don't want to use an error handler whilst testing code.

    You should use Option Explicit
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    You need to post an example workbook

  7. #7
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    royUK

    It's and Option Explicit

    I just forgot to copy that row

    I've attached the workbook I'm working on and this should all happen when you enter the number in colum A. That's the sheet name later.
    Attached Files Attached Files

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    this worked for me.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    eh? How can it work for you and not for me?
    I just tryed it and the cell B2 is still empty

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    What value did you enter in column A?

    What happens if you put a break point in the code and step through line by line?

  11. #11
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    The Value in column A? I just enterd the next number in the row that was 0005-2011 and it didn't copy the value.
    How do I step through line by line? :s

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    Goto to the code and with the cursor on the line

    Please Login or Register  to view this content.
    press F9 and the line should be hilited in red. Go back to the sheet and enter a value in column A. When the code runs it will stop at the red line. You can then press F8 to step through the code line be line.

  13. #13
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    So I did the F9 thig and entered a value in Column A and it did stop runing at the red line. And when I press F8 it goes down from the On error GoTo row but in color yellow and then it keeps doing this:

    Please Login or Register  to view this content.
    I go from the beggining of this code to the end and again to the beggining and the end and so on...nothing realy happens?

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    Does the code get to the important line where the sheet name is written into range B2?

  15. #15
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    No it's waaaaay up there. Doesn't get pass this code i said I keep getting back too.

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    That is a loop so I would expect it to go around abit. In you example file you have +50 worksheets.

    You can select the line
    Please Login or Register  to view this content.
    and use F9 to insert another break point. F5 will cause the code to run until it encounters the break. Might also be worth adding one at the start of the error trapping incase it fails before reaching it.
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    I've tryed the F9 at the If not SheetExists Then point but when I hit F5 it opens up a pop-up window Macros and I should run this Macro? but this Macro is not listed in the pop-up window.

  18. #18
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    You are working in an event routine rather than a standard code module so you need to fire the event rather than using ALT+F8 to run a macro.

    Update a cell on the worksheet, which will fire the event.
    When the code pauses you can then use F5 to resume exectution.

  19. #19
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    Ok so I went through it step by step. And Now the name was shown... I'm going to try it witouth the brake points to see if it will work.

    And nope. When I take out the brake points it doesn't work... and the column width stuff doesnt work.

  20. #20
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Comand in Makro not working

    I have no idea then

  21. #21
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    Ok so here is what I just did.
    I removed the:
    Please Login or Register  to view this content.
    Because the tabel and the command buttons are copyed as needed the right width and so on and in the right place and the Target.Name now works fine

  22. #22
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Comand in Makro not working

    Please Login or Register  to view this content.
    This is how the code looks like now. And it copys the name and the table like it's sopse too
    So Andy! If it wasn't for ur brake points I would never have seen that the column widht doesn't work. So U did it man!

+ 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