Results 1 to 6 of 6

Thread: using a macro

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    using a macro

    i have recorded a macro in excel now i want it to use in the vb . i hav copy it from VBA in the excel . now plz tellme how to use that code in vb .

  2. #2
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: using a macro

    FIRST ADD A REFERENCE TO YOUR PROJECT as excel.
    creaTE AN OBJECT OF TYPE eXCEL.aPPLICATION.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    Re: using a macro

    thanx its done
    tellme 1 more thing
    in my excel i hav a field name article num. ,what i want is that a code that checks the first column(article num) of the sheet till the article num is same, as a different article num comes it inserts a new row and adds the data of the column amount and writes it inti that row .

  4. #4
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: using a macro

    you can save previous cell value in a temparory variable.
    and for each record, check old value with current, if it is not same add a blank row then assign old value to current value.and so on..

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    Re: using a macro

    can u just give me an example code for that plzzz

  6. #6
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: using a macro

    VB Code:
    1. oldval=sheet1.cells(1,1)''''first val
    2. for i = 2 to allrecords
    3. if oldval <> sheet1.cells(i,1) then
    4.           'insert a blank row
    5.           oldval=sheet1.cells(i,1)
    6. end if
    7. next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width