Question: I have to rename my selected sheets (tabs of sheets) continuously in order to keep them updated with new additions i.e. sorting them based on new names, numbers or other criteria. 

I have made a table of all the names in one particular sheet and after processing that table (changing names, numbers etc) I want to use it to rename the currently selected sheets only. 

e.g. I select ANY 5 sheets and I want a code that will rename ONLY those 5 sheets based on FIRST FIVE values from the table in particular SHEET. 

I did little bit of scratch work as below but it's not leading me anywhere. 

```
Sub Sheets_Naming_current()

Dim ws As Worksheet, wb As Workbook
Dim nmRange As Range
Dim count As Integer

Set wb = ActiveWorkbook
Set nmRange = wb.Sheets("Totals").Range("D2:D25")
count = 0
On Error Resume Next
For Each ws In ActiveWindow.SelectedSheets
 count = count + 1     
      ws.Name = nmRange.Offset(i, 0).Value
Next ws

End Sub

```

Thanks in advance!

Answer: 
I guess you mean something like url encoding.

```
function gsearchquery(text) {
  var query = encodeURIComponent(text);
  return query;
}

```
Your current replace statement will replace only the first match.

Replacing your text replace statement with the following should solve it:

```
var query = text.replace(/\s+/g, "+");

```