Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to fetch data and display in Excel using Macro(VBA)

How to fetch data and display in Excel using Macro(VBA)

Scheduled Pinned Locked Moved Database
databasehelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tech_spidy
    wrote on last edited by
    #1

    Hi all, I can able to fetch a single data from Sql and display it in the Excel sheet using Macro, this is the code. I am getting in the Text Box: sno = TextBox1.Text When i am clicking the Ok button: Query = "Select sname,scity from smaster where snum='" & sno & "'" Set QueryRs = oConn.Execute(Query) Sheet1.Cells(1, 1) = QueryRs("sname") Sheet.Cells(1, 2) = QueryRs("scity") Result: Name, city displayed in the Excel sheet1 Now my problem is how to fetch multiple data and display (like how to use loop in it) waiting for timely help

    Tech_spidy

    T 1 Reply Last reply
    0
    • T Tech_spidy

      Hi all, I can able to fetch a single data from Sql and display it in the Excel sheet using Macro, this is the code. I am getting in the Text Box: sno = TextBox1.Text When i am clicking the Ok button: Query = "Select sname,scity from smaster where snum='" & sno & "'" Set QueryRs = oConn.Execute(Query) Sheet1.Cells(1, 1) = QueryRs("sname") Sheet.Cells(1, 2) = QueryRs("scity") Result: Name, city displayed in the Excel sheet1 Now my problem is how to fetch multiple data and display (like how to use loop in it) waiting for timely help

      Tech_spidy

      T Offline
      T Offline
      TomGarth
      wrote on last edited by
      #2

      Follow the link for 8 or 9 possible methods, including code samples. http://support.microsoft.com/kb/247412/EN-US/[^]

      Tom Garth Developer R. L. Nelson and Associates, Inc., Virginia

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups