Home > Mobile >  How to search excel cell in google and change the order of the cell contents?
How to search excel cell in google and change the order of the cell contents?

Time:02-02

I need to Google search names that are in an Excel cell.

I use =HYPERLINK("http://www.google.com/search?q=" & C5,C5).

However the names in the cell have the last name first, then the first name. How would I swap them around so they appear in google as first name then last name?

CodePudding user response:

String Modifiers in VBA:

  • Left() - Takes the left portion of a string up to specified number of characters
    =Left("DownFall", 4) Returns "Down"
  • Right() - same as Left() but from the right side
    =Right("DownFall", 4) Returns "Fall"
  • Mid() - Takes a string of characters from the middle of a string (from, number of char)
    =Mid("DownFall", 3, 4) Returns "wnFa"
  • find() - Returns the string position of specified sub string:
    =Find("F", "DownFall", 1) Returns "5"
  • TextSplit() Splits a string into multiple cells:
    =TextSplit("Down-Fall", "-") Returns "Down" and in cell 2 "Fall"

Note: there are many others, but you can accomplish most string manipulations with these few

Here is an example of them all together:

enter image description here

  • =LEFT(C5,FIND(",",C5,1)-1) & " " & MID(C5,FIND(" ",C5,1) 1,250)

enter image description here

  • =LEFT(C6,FIND(" ",C6,1)-1) & " " & MID(C6,FIND(" ",C6,1) 1,250)

enter image description here

CodePudding user response:

If last name is separated from first name with a comma, like this:

Smith, John

Then you can

Dim name
name =Split(Cells(row,column).value, ",")
Cells(row, column).value = name(1) & " " & name(0)
  • Related