Consulting

Results 1 to 13 of 13

Thread: Question How to put slash with word and ascending numbers in excel with VBA

  1. #1

    Question Question How to put slash with word and ascending numbers in excel with VBA

    How to put slash with word and ascending numbers in excel with VBA

    VBA.jpg


  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,199
    Location
    Hi sam10232321,

    This has been cross posted, links below.
    https://www.mrexcel.com/board/thread.../#post-6173314
    https://www.excelforum.com/excel-pro...-with-vba.html

    If you plan to cross post then you must show us the link to the other locations. People here help for free and it can be rather disheartening spending time working on something that could already be solved elsewhere.

    Worth reading the below about cross posting:
    https://excelguru.ca/a-message-to-forum-cross-posters/
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    Sorry how can I delete it?

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,199
    Location
    You don't need to delete it as I have posted the links, others will now know it has been cross posted and can check if it has been solved on those other sites. I was looking for you to understand why it is unfair to cross post without sharing the links to the other locations. Please read the last link I posted above, it will explain all.
    Last edited by georgiboy; 04-09-2024 at 11:14 AM. Reason: Duplicate word
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Something along the lines of
    Sub blah()
    Z = 1
    For Each cll In Range("A1:B21").SpecialCells(xlCellTypeConstants, 3).Cells
      cll.Value = cll.Value & "/category" & Z
      Z = Z + 1
    Next cll
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  6. #6
    Numbers are coming correctly like shown in my screenshot. Thank you

  7. #7
    Hi sorry just found out. The numbers are not coming as showing in my screenshot. Possible to fix it. Thanks in advance

  8. #8
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Screenshot to show how it's not working or a workbook please.

    Before:

    2024-04-10_100058.jpg

    After running macro:

    2024-04-10_100119.jpg

    What you said you wanted:

    2024-04-10_100531.jpg

    Please show me the differences between the last two.
    Or are you telling me you want the results in columns in D & E and not overwriting the data in columns A & B?
    Last edited by p45cal; 04-10-2024 at 02:12 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  9. #9
    Quote Originally Posted by p45cal View Post
    Screenshot to show how it's not working or a workbook please.

    Before:

    2024-04-10_100058.jpg

    After running macro:

    2024-04-10_100119.jpg

    What you said you wanted:

    2024-04-10_100531.jpg

    Please show me the differences between the last two.
    Or are you telling me you want the results in columns in D & E and not overwriting the data in columns A & B?
    I think that was he meant as seen in his example.
    and if you run you code again (accidentally?), the result is different.

  10. #10
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Quote Originally Posted by arnelgp View Post
    I think that was he meant as seen in his example
    Then change
    cll.Value = cll.Value & "/category" & Z
    to
    cll.Offset(, 3).Value = cll.Value & "/category" & Z
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  11. #11
    The numbers not coming as I wanted. Thank youvbaz.jpg

  12. #12
    I tested many times before and it was showing incorrectly. Now I tested again and it coming correctly as I wanted. well I am bit shocked how is that possible. Anyway really appreciate your time and helping with this formula. You saved alot of time. Thanks again.

  13. #13
    I tested many times before and it was showing incorrectly.
    test it again many times, if you are getting wrong result then it is processing by column, then by row.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •