PDA

View Full Version : Question How to put slash with word and ascending numbers in excel with VBA



sam10232321
04-09-2024, 07:39 AM
https://www.excelforum.com/images/icons/icon5.png How to put slash with word and ascending numbers in excel with VBA31495

georgiboy
04-09-2024, 07:58 AM
Hi sam10232321,

This has been cross posted, links below.
https://www.mrexcel.com/board/threads/how-to-put-slash-with-word-and-ascending-numbers-in-excel.1256949/#post-6173314
https://www.excelforum.com/excel-programming-vba-macros/1422231-how-to-put-slash-with-word-and-ascending-numbers-in-excel-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/

sam10232321
04-09-2024, 08:03 AM
Sorry how can I delete it?

georgiboy
04-09-2024, 08:10 AM
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.

p45cal
04-09-2024, 10:53 AM
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

sam10232321
04-10-2024, 12:48 AM
Numbers are coming correctly like shown in my screenshot. Thank you

sam10232321
04-10-2024, 01:25 AM
Hi sorry just found out. The numbers are not coming as showing in my screenshot. Possible to fix it. Thanks in advance

p45cal
04-10-2024, 01:38 AM
Screenshot to show how it's not working or a workbook please.

Before:

31496

After running macro:

31497

What you said you wanted:

31498

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?

arnelgp
04-10-2024, 02:54 AM
Screenshot to show how it's not working or a workbook please.

Before:

31496

After running macro:

31497

What you said you wanted:

31498

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.

p45cal
04-10-2024, 03:06 AM
I think that was he meant as seen in his exampleThen change
cll.Value = cll.Value & "/category" & Zto
cll.Offset(, 3).Value = cll.Value & "/category" & Z

sam10232321
04-10-2024, 03:23 AM
The numbers not coming as I wanted. Thank you31499

sam10232321
04-10-2024, 03:30 AM
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.

arnelgp
04-10-2024, 03:38 AM
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.