How to put slash with word and ascending numbers in excel

Sam1023423

New Member
Joined
Apr 9, 2024
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
  2. Web
How to put slash with word and ascending numbers in excel with VBA
Thanks in advance.
VBA.jpg
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Do you really need to do it in VBA? Its quite a simple formula:

Column D Cell 1
=IF(A1="","",A1&"Category/"&ROW())

Column E Cell 1
=IF(B1="","",B1&"Category/"&ROW()+1)
 
Upvote 0
Hi Rob
Yes I need VBA formula because I have 10000 categories.
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Question How to put slash with word and ascending numbers in excel with VBA
and How to put slash with word and ascending numbers in excel with VBA
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
The above one working fine but it put numbers before words and I need after words

Sub marine()
Dim n As Long
Dim r As Range
n = 10000

For Each r In ActiveSheet.UsedRange
If r.Value <> "" Then
r.Value = n & "/" & r.Value
n = n + 2
End If
Next r
End Sub
 
Upvote 0
Try
VBA Code:
Sub AppendCategories()
    Dim a, b
    Dim i As Long, j As Long
    Dim numRow As Long, counter As Long
    Dim ws As Worksheet
   
    Set ws = ThisWorkbook.Worksheets("Sheet1")  'Change as needed
    numRow = Cells(Rows.Count, "B").End(xlUp).Row
    a = ws.Range("A1:B" & numRow).Value
    counter = 1
   
    ReDim b(1 To numRow, 1 To 2)
   
    For i = 1 To numRow
        For j = 1 To 2
            If Not IsEmpty(a(i, j)) Then
                b(i, j) = a(i, j) & "/category" & counter
                counter = counter + 1
            End If
        Next j
    Next i
   
    ws.Range("D1").Resize(UBound(b, 1), 2).Value = b

End Sub
 
Upvote 0
Sub blah()
Z = 1
For Each cll In Range("A1:D1000").SpecialCells(xlCellTypeConstants, 3).Cells
cll.Value = cll.Value & "/c" & Z
Z = Z + 1
Next cll
End Sub

This one working but numbers are not coming like show in my screenshot.
 
Upvote 0
Have you tried the code in #7? If you did, what didn't work?
 
Upvote 0

Forum statistics

Threads
1,215,261
Messages
6,123,931
Members
449,134
Latest member
NickWBA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top