Results 1 to 7 of 7

Thread: automatic Copy down in excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    automatic Copy down in excel

    I have written a macro that does some fancy formatting and adding columns etc. I want to copy down the formulas in two columns down to the end of the list. The last part of the macro will then copy the results of the formulas, paste special them as values and delete a couple of columns. What I am looking for is a piece of code that will take the two formulas and copy them down to the end of the list. In the moment there are two macros and I have to manually copy the formulas down by using the double click on the right hand corner of the cell function. I'd like to see it as one macro. I'd be happy to copy the code so you can see it if you have any idea what I want to do.

    Any help would be greatly appreciated.
    Regards.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: automatic Copy down in excel

    Excel VBA question moved to Office Development

  3. #3
    Lively Member
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    66

    Re: automatic Copy down in excel

    Can you paste the code - pasting the code might give us a better picture.

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: automatic Copy down in excel

    Welcome to the forum!

    You should use the .FillDown method of the range object to copy the formulas down.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: automatic Copy down in excel

    Can't you copy the cell with the formula, then set a range to the area to paste it in and paste it?

    Repeat for the second column...


    If the columns are together, then use one copy and paste loop.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Re: automatic Copy down in excel

    Quote Originally Posted by DKenny
    Welcome to the forum!

    You should use the .FillDown method of the range object to copy the formulas down.
    Thanks DKenny.

    I thought of that, but can't work out how to tell the code to always fill to the end of the data. I have to give it a range, but how to I say: Just keep filling until you get to the end.

    I'm probably not going about it the right way.

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Re: automatic Copy down in excel

    Hi Guys.

    Here is the code. I thought it might help.

    Regards.
    Roland

    Quote Originally Posted by whiteWay
    Can you paste the code - pasting the code might give us a better picture.
    VB Code:
    1. Range(Selection, Selection.End(xlDown)).Select
    2.     ActiveCell.Offset(0, 1).Columns("A:B").EntireColumn.Select
    3.     Selection.Insert Shift:=xlToRight
    4.     ActiveCell.Select
    5.     ActiveCell.FormulaR1C1 = "=RC[-1]+19000000"
    6.     ActiveCell.Offset(0, 1).Select
    7.     ActiveCell.FormulaR1C1 = _
    8.     "=VALUE(RIGHT(RC[-1],2)&""/""&+MID(RC[-1],5,2)&""/""&+LEFT(RC[-1],4))"
    9.     ActiveCell.Columns("A:A").EntireColumn.Select
    10.     Selection.NumberFormat = "d/m/yyyy"
    11.     ActiveCell.Select
    12.     ActiveCell.Offset(0, -1).Range("A1:B1").Select
    13.     'Selection.AutoFill Destination:=ActiveCell.Range("")

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