Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 836863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:03:04+00:00 2026-05-15T05:03:04+00:00

I have an Excel spreadsheeet with a cell containing a concatenated name and surname

  • 0

I have an Excel spreadsheeet with a cell containing a concatenated name and surname (don’t ask why). For example, Cell A2: BLOGGSJOE.

On this cell, I would like to run the following SQL and output it to cell A3, A4 and A5:

SELECT i.id, i.forename, i.surname FROM individual i  WHERE UPPER(REPLACE('" & A2 & "', ' ', '')) =  UPPER(REPLACE(i.surname|| i.forename, ' ', ''))  AND NVL(i.ind_efface, 'N') = 'N'

Any idea how I could perform an Oracle query on each cell and return the result?

I have enabled an Oracle datasource connection in Excel, just not sure what to do now.

Is this a stupid approach, and can you recommend a better more proficient way?

I am aware that I could just write a simple Ruby/PHP/Python/whatever script to loop through the Excel spreadsheet (or .csv file) and then perform the query etc. but I thought there might be a quick way in Excel itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:03:05+00:00Added an answer on May 15, 2026 at 5:03 am
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sql As String
    
    Set cn = New ADODB.Connection
    cn.ConnectionString = 'Get one from http://www.connectionstrings.com/oracle 
    'eg. "Driver={Oracle in OraHome92};Dbq=tns;Uid=uid;Pwd=pwd;"
    cn.Open
    
    sql = Your SQL
    
    Set rs = cn.Execute(sql)
    
    for loop or something to paste records
    
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing
    

    if you format your spreadsheet properly you could assign rs to a Variant and then assign the variant to a range instead of looping through it.

    Edit

    With your current SQL you would need to loop through each cell and query the db, then save the results to A3:A5. Edit 2, Something like that:

    Private Function GetRow(user As String) As Variant
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sql As String
    Dim v As Variant
    
    Set cn = New ADODB.Connection
    cn.ConnectionString = "Driver={Oracle in OraHome92};Dbq=tns;Uid=uid;Pwd=pwd;"
    cn.Open
    
    sql = "SELECT i.id, i.forename, i.surname FROM individual i  WHERE UPPER(REPLACE('" & user & "', ' ', '')) =  UPPER(REPLACE(i.surname|| i.forename, ' ', ''))  AND NVL(i.ind_efface, 'N') = 'N'"
    
    Set rs = cn.Execute(sql)
    
    v = rs.GetRows()
    GetRow = v
    
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing
    End Function
    
    Sub a()
    Dim user As String
    For i = 2 To x
        user = ActiveSheet.Cells(i, 1).Value
    
        GetRow (user)
        ActiveSheet.Cells(i, 2).Value = GetRow(0)
        ActiveSheet.Cells(i, 3).Value = GetRow(1)
        ActiveSheet.Cells(i, 4).Value = GetRow(2)
    
    Next
    
    End Sub
    

    Note that I have used different cells that you wanted and the GetRow is 2D not 1D, but is hard for me to write it up with no access to actual spreadsheet/db

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Excel Spreadsheet with lab data which looks like this: µg/L (ppb)
I have some data structured like this in an Excel spreadsheet: A B C
I have a basic excel spreadsheet like this: A B C D etc.. 10%
I have an Excel Spreadsheet like this id | data for id | more
I have an Excel spreadsheet that looks like: spreadsheet http://img186.imageshack.us/img186/6495/exelf.jpg I'd like to convert
I have an excel spreadsheet that is password-protected. I need to open this spreadsheet
I am using Apache POI-HSSF for working with Excel files. I have a cell
I have an Excel 2007 spreadsheet with date entries in this format m/d/yyyy h:mm
I'm having some trouble reading from an Excel spreadsheet in C#. I have this
How can I have a macro automatically run whenever a cell in my Excel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.