1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

read Excel file by VBA?

Discussion in 'Business Applications' started by al_samirr, Dec 12, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. al_samirr

    al_samirr Thread Starter

    Joined:
    Nov 28, 2006
    Messages:
    7
    I have excel file consist of two columns.
    I want to read its cells and store it into variables (for each row)
    please help
     
  2. Jimmy the Hand

    Jimmy the Hand

    Joined:
    Jul 28, 2006
    Messages:
    1,223
    Hi, and welcome to TSG forum.

    The info you gave is not enough to give an exact solution to your question.
    However, a general one might help you as well. So, in general, you can use the code below.
    All that are in italic characters are to be replaced with the names and values you use.

    Code:
    [I]variablename[/I] = Workbooks("[I]workbookname[/I]").Sheets("[I]sheetname[/I]").Cells([I]rowindex, columnindex[/I]).Value
    
    Also, if you want to refer to a cell of current workbook, current sheet, you can use simply
    Code:
    [I]variablename[/I] = Activesheet.Cells([I]rowindex,columnindex[/I]).Value
    
    E.g. to store value of cell "C2" of the current sheet in variable "A" you need
    Code:
    A = Activesheet.Cells(2, 3).Value
    For more help, please provide more info about what you need.
     
  3. al_samirr

    al_samirr Thread Starter

    Joined:
    Nov 28, 2006
    Messages:
    7
    Thank you very much
    That's it
    I benefited from your help.

    thanks again
     
  4. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    al_samirr,

    It is not even clear the context to which you're talking about. For your benefit - and others who search this board - would you mind explaining in detail what it is you are talking about?
     
  5. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    You may also want to explore the option of putting the values into an array instead of using seperate variables for each row of data.

    Rollin
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/526064

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice