• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

extract data from excel into vb

Hi,
Can anyone of you experts show me example of coding that extract data in the excel into vb?

I have this excel file that contain few columns (assume to be 3 columns) and rows (assume 10 rows)
I want to extract data in the SECOND column but start at Third row and put the data into a formula that i already write the code in vb. The process repeat for the next row with the same column until it reach the last row ( 10th row). When it reach there, a msgbox will popup.
Also when all this finish, the excel file will close itself and save itself into hard disk (if file already exist, overwrite it).

i think this is simple to you guys. i'm very new to vb (actually never use or learn vb before). So need your help very much. Sound desperate huh!? :)
0
michelle_branch
Asked:
michelle_branch
1 Solution
 
bhagyeshtCommented:
take a form
add microsoft excel's reference.
add a command button and the following code
this will help you start with.

Private Sub Command1_Click()
    Dim myapp As New Excel.Application
    Dim myWB As Excel.Workbook
    Dim myWS As Excel.Worksheet
    Set myWB = myapp.Workbooks.Open("c:\myfile.xls")
    myapp.Visible = True
    Set myWS = myWB.Sheets("sheet1")
    MsgBox myWS.Range("A1").Value
    myWB.Save
    Set myWS = Nothing
    myWB.Close
    Set myWB = Nothing
    myapp.Quit
    Set myapp = Nothing
End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now