Hello,
I am importing a lot of survey data from various files into Excel, which gets pasted using the paste special Paste:=xlPasteAll command in VB. One of the columns is full of GPS co-ordinates, formatted as a Google maps link. Most of these are pasted correctly, but occasionally a large set of them get pasted as plain text with no link. I cannot find any reason for this, it appears to be entirely random; there is nothing wrong with the source data (which is a HTML file produced by the survey trolley, opened in Excel and then the various bits are then copied out of it automatically).
I want to run a sub that converts them back into maps links. I have tried the HYPERLINK function, which does what I want but I don't really want the formulas to remain; I just want the hyperlink itself. I cannot get Excel to copy and paste the result of HYPERLINK as HTML, unless I copy it into word first and then copy it back. I've tried various bits of VB code from around the web, but none of them seem to do what I want.
I want a method of replacing the GPS plain text with hyperlinks in the following format:
, use that as the hyperlink and then display the GPS text from column A. (Formatted as code to prevent the forum turning the link into a hyperlink instead of displaying plain text).
I tried to use this code I found here, which I modified slightly with the variable 'TextToDisplay'. It did part of the job, in that it turned the text format google link into a hyperlink, but I couldn't get it to change the displayed text from the full web address to just the GPS address. The code also stops working sometimes, for reasons beyond my skill level (novice).
Thanks in advance,
Dan E
I am importing a lot of survey data from various files into Excel, which gets pasted using the paste special Paste:=xlPasteAll command in VB. One of the columns is full of GPS co-ordinates, formatted as a Google maps link. Most of these are pasted correctly, but occasionally a large set of them get pasted as plain text with no link. I cannot find any reason for this, it appears to be entirely random; there is nothing wrong with the source data (which is a HTML file produced by the survey trolley, opened in Excel and then the various bits are then copied out of it automatically).
I want to run a sub that converts them back into maps links. I have tried the HYPERLINK function, which does what I want but I don't really want the formulas to remain; I just want the hyperlink itself. I cannot get Excel to copy and paste the result of HYPERLINK as HTML, unless I copy it into word first and then copy it back. I've tried various bits of VB code from around the web, but none of them seem to do what I want.
I want a method of replacing the GPS plain text with hyperlinks in the following format:
Code:
"https://maps.google.com/?q=" &"{GPS data from column A}" & "&iwloc=A&t=h&z=17"
I tried to use this code I found here, which I modified slightly with the variable 'TextToDisplay'. It did part of the job, in that it turned the text format google link into a hyperlink, but I couldn't get it to change the displayed text from the full web address to just the GPS address. The code also stops working sometimes, for reasons beyond my skill level (novice).
VBA Code:
Sub Convert_Hyperlink()
For Each x In Selection
ActiveSheet.Hyperlinks.Add Anchor:=x, Address:=x.Formula, TextToDisplay:=x.Value
Next x
End Sub
Thanks in advance,
Dan E
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B31 | B2 | =HYPERLINK("https://maps.google.com/?q="&A2&"&iwloc=A&t=h&z=17",A2) |
C2:C31 | C2 | =TEXT("https://maps.google.com/?q="&B2&"&iwloc=A&t=h&z=17",B2) |