Forum Discussion

aknadler's avatar
aknadler
Copper Contributor
Aug 02, 2023

Aligning 1st and Last name column in Excel with similar .jpg file name in separate column for SQL

I have an excel spreadsheet. I have a column listed for first name and another column for last name. I have another column for JPEG images. The file name is similar to the name which is Lastname_Firstname.jpg. I need to line up and match the human name to the .jpg file name horizontally on a different column. Can this be done using a function or formula? I am initially importing the file into SQL.  I understand the Vlookup and Xlookup functions but is there a direct function or formula that I can use that will automatically pull the .jpg filenames from a separate column and align them next to the column of names. Assuming I would use the Last name for the similar data point as it would be shared between the human name and .jpg name.

  • Fares_Alabsi's avatar
    Fares_Alabsi
    Copper Contributor
    You can use the **CONCATENATE** function to line up and match the human name to the .jpg file name horizontally on a different column. The **CONCATENATE** function allows you to combine text and values into a single string.

    In your case, you would use the **CONCATENATE** function to combine the last name and first name from the first two columns, and then append the .jpg extension. For example, if the last name is "Doe" and the first name is "John", you would use the following formula:

    ```
    =CONCATENATE(LastName, "_", FirstName, ".jpg")
    ```

    This would create the string "Doe_John.jpg". You could then copy and paste this formula into the third column, and it would automatically match the human name to the .jpg file name.

    Here is an example of how you would use the **CONCATENATE** function to match the human name to the .jpg file name in Excel:

    ```
    =CONCATENATE(A2, "_", B2, ".jpg")
    ```

    In this example, the first two arguments of the **CONCATENATE** function are the cells that contain the last name and first name. The third argument is the .jpg extension. The result of the formula would be the .jpg file name, which would be placed in the cell that contains the formula.
  • mtarler's avatar
    mtarler
    Silver Contributor
    so maybe if you provided a sample file we might understand better but if all you need is to have a 3rd column that says what the jpg filename is and that filename is Lastname_Firstname.jpg then couldn't you just use (assuming firstname in col A and lastname in col B)
    =B1&"_"&A1&".jpg"
    and fill down or in excel 365 assuming rows 1:1000
    =B1:B1000&"_"&A1:A1000&".jpg"
    • aknadler's avatar
      aknadler
      Copper Contributor

      mtarler  Thank you for your response.  See sample file.  Names have been changed, but basically I have copied the file name from the folder and pasted into a column on the document.  There are 684 names and over 1000 .jpg file names, so they do not line up if I try to ascend and alphabetically.  I am trying to get the Lastname_Firstname.JPG file to line up as seen in rows 10-13, I inputted these in manually.  

       

      I appreciate your assistance with this.

       

      Thank you!

       

      LastNameFirstNameImageDataJPEG
      abbotPaul Ackerman_Erin.jpg
      AbbottAdam Acosta_Alexandria.JPG
      Abbott Jeff P. Acosta_Angie.jpg
      AdyeAustin Acosta_Olga.JPG
      Allenjill Adams_Mikey.JPG
      AllenChandra Adams_Sam.JPG
      Almanza Flores Angel D. Adams_Thomas.JPG
      Alvarez Veronica Adriana.JPG
      Amaya ErikaAmaya_Erika2.JPGAdye_Austin.JPG
      Anderson LoganAnderson_Logan.JPGAerni_Shannon.jpg
      ArcherDeborahArcher_Debi.JPGAffolter_Brandon.jpg
      ArchibaldJoshuaArchibald_Josh.JPGAffolter_Brandon2.JPG
      ArnesonBryan Abbot_Paul.JPG
      Aufdermauer Faith N. Abbot_Adam.JPG
      Ayala Sanchez Ana G. Abbot_Jeff
      AyersJon Adye_Austin.JPG
      BaladezMabelyn Allen_Jill.jpg
      BalesJustin Allen_Chandra.jpg
      BarberRichard Arneson_Bryan
      Barbour Maximilian L. Aufdermaur_Faith.jpg

Resources