+ Reply to Thread
Results 1 to 9 of 9

How to use VBA to drag down ?

  1. #1
    Forum Contributor
    Join Date
    07-18-2006
    Posts
    135

    Question How to use VBA to drag down ?

    i have 2 col
    - fisrt and second col contain value (exiset already)

    How to use VBA to minus them an drag down at third col to end of row of col 1 or 2

    EX: col 1 and 2 have 1000 rows
    therefore, col 3 will be 1000 result rows automatically
    Thanks for your help .
    Last edited by vumian; 07-19-2006 at 02:53 PM.

  2. #2
    Dave Peterson
    Guest

    Re: How to use VBA to drag down ?

    Option Explicit
    Sub testme()
    Dim LastRow As Long

    With Worksheets("sheet1")
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    .Range("c1:C" & LastRow).FormulaR1C1 _
    = "=rc[-2]-rc[-1]"
    End With
    End Sub




    vumian wrote:
    >
    > i have 2 col
    > - fisrt and second col contain value (exiset already)
    >
    > How to use VBA to minus them an drag down at third col to end of row of
    > col 1 or 2
    >
    > EX: col 1 and 2 have 1000 rows
    > therefore, col 3 will be 1000 result rows automatically
    > Thanks for your help .
    >
    > --
    > vumian
    > ------------------------------------------------------------------------
    > vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
    > View this thread: http://www.excelforum.com/showthread...hreadid=563001


    --

    Dave Peterson

  3. #3
    Forum Contributor
    Join Date
    07-18-2006
    Posts
    135
    ths very, but i take extend my thinks following :

    if they are 2 cols random, not next to each other above.
    how to do it, pls

  4. #4
    Dave Peterson
    Guest

    Re: How to use VBA to drag down ?

    You'll still need to pick out one of the columns that can define where that last
    used row is.

    LastRow = .Cells(.Rows.Count, "X").End(xlUp).Row

    And you'll have to adjust this to match the column that you're putting the
    formula. In fact, I'd change it to something like:

    Option Explicit
    Sub testme()
    Dim LastRow As Long
    dim FirstCol as Long
    dim SecondCol as long
    dim FormCol as long

    with worksheets("Sheet1")
    firstcol = .range("e1").column 'I used column 5 (E)
    SecondCol = .range("Z1").column 'I used column 26 (Z)
    FormCol = .range("AZ1").column 'I used column 52 (AZ)

    'using the first column to get the longest row
    Lastrow = .cells(.rows.count,firstcol).end(xlup).row

    .range(.cells(1,formcol),.cells(lastrow,formcol)).formula _
    = "=" & .cells(1,firstcol).address(0,0) _
    & "-" & .cells(1,secondcol).address(0,0)

    end with

    end sub



    vumian wrote:
    >
    > ths very, but i take extend my thinks following :
    >
    > if they are 2 cols random, not next to each other above.
    > how to do it, pls
    >
    > --
    > vumian
    > ------------------------------------------------------------------------
    > vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
    > View this thread: http://www.excelforum.com/showthread...hreadid=563001


    --

    Dave Peterson

  5. #5
    Forum Contributor
    Join Date
    07-18-2006
    Posts
    135

    Question

    Oke, ths, it runs well.

    i also get one small thing more, pls help me

    Col A stores Number as Text
    How to convert it from row 1 or 2 to end of 'Number as Text' to value
    row 1- title is present a real text.

    thanks for your help.
    Last edited by vumian; 07-20-2006 at 12:06 PM.

  6. #6
    Dave Peterson
    Guest

    Re: How to use VBA to drag down ?

    Select an empty cell.
    edit|copy
    select column A
    edit|Paste special|check addition

    If you need this in your macro, record a macro and you'll see useable code.

    vumian wrote:
    >
    > Oke, ths, it runs well.
    >
    > i also get one small thing more, pls help me
    >
    > Col A stores Number as Text
    > How to convert it to end of 'Number as Text' ,
    > row 1- title is present a real text.
    >
    > thanks for your help.
    >
    > --
    > vumian
    > ------------------------------------------------------------------------
    > vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
    > View this thread: http://www.excelforum.com/showthread...hreadid=563001


    --

    Dave Peterson

  7. #7
    Forum Contributor
    Join Date
    07-18-2006
    Posts
    135

    Thumbs up

    oh,i've not ever thought it before,) so great great, you're good man , :P
    thank you very much.

  8. #8
    Chris
    Guest

    Re: How to use VBA to drag down ?

    I think it's so cool that you help others whose first language is not
    English. Way to go Dave. Yes, you are a good man. I agree with vumian.
    --
    Chris

    "Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
    news:44BFA9E4.94EBDFB7@verizonXSPAM.net...
    | Select an empty cell.
    | edit|copy
    | select column A
    | edit|Paste special|check addition
    |
    | If you need this in your macro, record a macro and you'll see useable
    code.
    |
    | vumian wrote:
    | >
    | > Oke, ths, it runs well.
    | >
    | > i also get one small thing more, pls help me
    | >
    | > Col A stores Number as Text
    | > How to convert it to end of 'Number as Text' ,
    | > row 1- title is present a real text.
    | >
    | > thanks for your help.
    | >
    | > --
    | > vumian
    | > ------------------------------------------------------------------------
    | > vumian's Profile:
    http://www.excelforum.com/member.php...o&userid=36494
    | > View this thread:
    http://www.excelforum.com/showthread...hreadid=563001
    |
    | --
    |
    | Dave Peterson



  9. #9
    Dave Peterson
    Guest

    Re: How to use VBA to drag down ?

    There are lots of people in these groups that help people--no matter what the
    OP's mother tongue is--be it English, VBA or even binary <vbg>.


    Chris wrote:
    >
    > I think it's so cool that you help others whose first language is not
    > English. Way to go Dave. Yes, you are a good man. I agree with vumian.
    > --
    > Chris
    >
    > "Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
    > news:44BFA9E4.94EBDFB7@verizonXSPAM.net...
    > | Select an empty cell.
    > | edit|copy
    > | select column A
    > | edit|Paste special|check addition
    > |
    > | If you need this in your macro, record a macro and you'll see useable
    > code.
    > |
    > | vumian wrote:
    > | >
    > | > Oke, ths, it runs well.
    > | >
    > | > i also get one small thing more, pls help me
    > | >
    > | > Col A stores Number as Text
    > | > How to convert it to end of 'Number as Text' ,
    > | > row 1- title is present a real text.
    > | >
    > | > thanks for your help.
    > | >
    > | > --
    > | > vumian
    > | > ------------------------------------------------------------------------
    > | > vumian's Profile:
    > http://www.excelforum.com/member.php...o&userid=36494
    > | > View this thread:
    > http://www.excelforum.com/showthread...hreadid=563001
    > |
    > | --
    > |
    > | Dave Peterson


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1