Results 1 to 4 of 4

Thread: How to define range in vb6 and to be written in excel

  1. #1
    Join Date
    Feb 2009
    Posts
    78

    How to define range in vb6 and to be written in excel

    I used Excel file to make some computational work, and the number of rows have been filled with the numbers and when I do the computation for these numbers then sometimes its value remains countless and that i traced out two to three times, does anyone knows how to write range for number of rows to calculate.

    Thanks

  2. #2
    Join Date
    Feb 2006
    Posts
    167

    Re: How to define range in vb6 and to be written in excel

    Yes, you need to add the Microsoft Scripting Runtime reference. May I ask if you are creating the Excel file with it or ??? go to the "Project" menu, and select "References". You will be presented with a long list of available references, just scroll down to "Microsoft Excel X.X Object Library"

  3. #3
    Join Date
    Mar 2008
    Posts
    433

    Re: How to define range in vb6 and to be written in excel

    If you wanted to wtrte the give Add a reference to Microsft excel object library:

    Option Explicit

    Private Sub Command1_Click()
    Dim xlApp As Excel.Application
    Dim wb As Workbook
    //You need to wite the following source code then you need to set up an answer.

    Set xlApp = New Excel.Application

    Set wb = xlApp.Workbooks.Open("PATH TO YOUR EXCEL FILE")

    Set ws = wb.Worksheets("Excel Sheet1") 'Specify your worksheet name
    var = ws.Range("A1").Value

    or
    var = ws.Cells(1, 1).Value
    wb.Close

    xlApp.Quit

  4. #4
    Join Date
    Feb 2009
    Posts
    117

    Re: How to define range in vb6 and to be written in excel

    Although your Typename <> "Nothing" left me perplexed. Instead of a string compare, you have a reference set up, you can create an instance of Excel. To do this you declare an object variable with a data type of Excel.Application, and then you can do whatever you want with it, before closing/disconnecting from it. Or else you can open an existing worksheet file and read it, you can create a new one and save it, you can basically do anything that a user in Excel can do.

Similar Threads

  1. How to paste range of name list in Excel worksheet
    By vALaNCiA in forum Windows Software
    Replies: 3
    Last Post: 11-01-2012, 06:10 PM
  2. Select a range of sheets in Excel VBA
    By RyanInt in forum Software Development
    Replies: 6
    Last Post: 16-01-2010, 11:47 AM
  3. Define the format of a cell in excel 2003
    By geokilla in forum Windows Software
    Replies: 3
    Last Post: 02-10-2009, 11:23 AM
  4. Excel range finder
    By ManishS in forum Windows Software
    Replies: 2
    Last Post: 25-06-2009, 11:26 AM
  5. Replies: 3
    Last Post: 09-06-2009, 07:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,506,949.05179 seconds with 17 queries