Nicknames in front of text

Sekiro

New Member
Joined
Aug 29, 2023
Messages
8
Office Version
  1. 2021
Platform
  1. Windows
Hello. I would like to know if in Excel it’s possible to add a nickname in front of a text that I can drag down and automatically the next nicknames will be added in front of the company.

I attach a photo of what I actually mean, because I’m not sure how to explain it.

Something like G1 in front of Nike company and dragging down will appear G2 in front of another company, G3 in front of a different one, G4… G5 etc…

Or if there are another solutions and ways to do this, please let me know, because I have over 5000 addresses to witch I need to add this nickname in front.
 

Attachments

  • Numbers excel.png
    Numbers excel.png
    27.5 KB · Views: 13

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I would add a column to the left of it and use this formula:
="G"&ROWS($A$1:A1)

otherwise it would take VBA to insert it and color it red.
 
Upvote 0
The colour and the size of the nickname doesn’t matter to be honest.
My concern is that those nicknames needs to be in front of the text on the same cell.
I’m familiar with VBA, but not so much to do such a code
 
Upvote 0
To do it in the same row, you cannot use a formula, or else you would lose your existing values, unless you use VBA.
Anytime you drag a formula down, it will overwrite whatever is currently in the cell with whatever your formula is.
So your dragged down formula would overwrite all of your current values.

We can help you come up with the VBA code you need, if you can answer the following questions:
1. Will the first value ALWAYS have a nickname of "G1"? If not, what is the logic that determines this (or would you like a prompt for them to enter something)?
2. Will the first value ALWAYS go in cell H2? If not, what is the first cell, or what is the logic for determining the first cell to put this in?
 
Upvote 0
Hello. Thank you very much for the help.

To answer your questions:

1. Yes. The first value will be always G1

2. Yes. The nickname will be first following the company name. For example: G1 Nike.
 
Upvote 0
Try this:
VBA Code:
Sub AddNicknames()

    Dim lr As Long, r As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column H with data
    lr = Cells(Rows.Count, "H").End(xlUp).Row
    
'   Check for data in column H
    If lr > 1 Then
'       Loop through each row in column H
        For r = 2 To lr
'           Update entry in column H to add nickname
            Cells(r, "H") = "G" & r - 1 & " " & Cells(r, "H").Value
        Next r
    End If
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 1
Solution
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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