Can I move cells to the right for each "/" ?

Arana

New Member
Joined
Dec 20, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I am making an index of a large number of files with a very long path, and I need that for each "/" each cell moves to the right. That is, if there are 3 "/" in a cell, that same cell must be moved 3 times to the right.
is there a way to apply this to all my excel sheet?
All help is welcome.

1671530562136.png
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Maybe something like:
VBA Code:
Sub test()
    Dim rCell As Range, fsNum As Integer
    
    For Each rCell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Cells
        fsNum = Len(rCell) - Len(Replace(rCell, "/", ""))
        rCell.Offset(, fsNum) = rCell
        rCell = vbNullString
    Next rCell
End Sub
 
Upvote 0
Solution
Maybe something like:
VBA Code:
Sub test()
    Dim rCell As Range, fsNum As Integer
   
    For Each rCell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Cells
        fsNum = Len(rCell) - Len(Replace(rCell, "/", ""))
        rCell.Offset(, fsNum) = rCell
        rCell = vbNullString
    Next rCell
End Sub
It worked! thank you very much. (y)
 
Upvote 0
The marked solution has been changed accordingly.
In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,856
Members
449,194
Latest member
HellScout

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