+ Reply to Thread
Results 1 to 20 of 20

Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

  1. #1
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Hello everyone,

    I have to following macro running in the attached workbook "proba2":

    Please Login or Register  to view this content.
    First of all, the macro doesn't completely change every "." to "," in the selected range, and also pops up an error message (Run-time error: '1004') referring to the highlighted row of the macro.

    Here's a detailed process, what I want the macro to do:

    1. Delete the first row
    2. Select column H, and divide it to multiple columns using "|" (Alt Gr+W) as a divider.
    3. Select the created columns H-K and swap every "." with ","
    4. Create a bar graph from column K

    Any ideas to make it work?
    Attached Files Attached Files
    Last edited by H.Gabor; 07-26-2018 at 05:50 AM.

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    To fix the error message try changing;
    Please Login or Register  to view this content.

  3. #3
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    And I can't see any "." in Columns H:K after the macro runs.

  4. #4
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Thank you, yes it works like that, but the name of the sheet might not always be the same, so I wanted to come up with a solution for that.

  5. #5
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    That is the problem, I get nothing instead of "," especially in column K. For example a value should be 3,000 after the change, but it shows up like 3 000.

  6. #6
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    I guess Excel thinks 3.000 is 3 and strips the zeroes and comma before you can replace it.

  7. #7
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    When you do your text to columns select Text as the Column Data Format.

  8. #8
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Try changing these values;
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    It seems to just get rid of the blank between the first and second digit. Here's my macro now:

    Please Login or Register  to view this content.
    Last edited by H.Gabor; 07-26-2018 at 05:50 AM.

  10. #10
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Did you see Post #8?

  11. #11
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    It also comes with the same result as the previous Cell Type solution it seems.
    It's interesting that for some cells it works but for others it doesn't.
    Attached Images Attached Images

  12. #12
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Give an example of what doesn't work now? I can't tell from the screenshot.

  13. #13
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    If you look at the screenshot, every value from column H-K should be looking like the ones with the little green mark in the top left corner.
    So K1 should be 4,7. K2 would be 6,1 etc.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Do you mean?
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    This one seems to be working, can you make it so it covers columns K-H? The part when it swaps "." to "," I mean.

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Before anything you need to edit all your posts and add code tags.
    It's a rule in the forum.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Last edited by jindon; 07-26-2018 at 05:55 AM.

  17. #17
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    Sorry, it is now fixed, i think.

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    OK, thanks for the code tags.

    This should do
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    07-05-2018
    Location
    Győr, Hungary
    MS-Off Ver
    MS Office Excel 2010
    Posts
    20

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    This works wonderfully, thank you so much.
    Last edited by H.Gabor; 07-26-2018 at 06:34 AM.

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.

    You are welcome and thanks for the rep.

+ 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: 3
    Last Post: 05-02-2018, 08:03 AM
  2. Replies: 35
    Last Post: 01-13-2016, 02:16 AM
  3. Replies: 4
    Last Post: 11-13-2015, 09:03 PM
  4. [SOLVED] VBA help needed to remove all "/" then replace with "-" from cell "B3"and "B5"
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2014, 02:11 PM
  5. get "run time error 1004" when i try to activate macro on protected sheet why?
    By ASAFSWIS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2013, 11:37 AM
  6. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  7. Excel 2007 : Macro gives a "run time error '1004'"
    By grsnipe in forum Excel General
    Replies: 1
    Last Post: 10-15-2010, 02:37 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