1. OzGrid
    1. Excel/VBA Consultancy
    2. OzGrid Store
    3. Training
    4. Freebies
  2. Forum
    1. Unresolved Threads
    2. Forum Rules
  3. Dashboard
  4. Articles
  5. Members
    1. Recent Activities
    2. Users Online
    3. Team
    4. Search Members
  • Login or register

    Login

    Lost Password

    Register

    Don’t have an account yet? Register yourself now and be a part of our community!

    Register Yourself
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • More Options
  1. OzGrid Free Excel/VBA Help Forum
  2. HELP FORUMS
  3. Excel General

Autofill?

  • wofinufu
  • Feb 11th 2021
  • wofinufu
    Beginner
    Points
    5
    Posts
    1
    • Feb 11th 2021
    • #1

    I am new to the forum so thanks for the warm welcome everyone!

    I am trying to take Column A multiply it by some pre-calculated factor D1 with the output in Column B.

    Normally I would just use autofill, but this is sheet could have any number of rows. I found the following snippet, but it doesn't quite work for me.

    Code
    1. Range("A1").Select
    2. numRows = Range(Selection, Selection.End(xlDown)).Rows.Count
    3. Selection.AutoFill Destination:=Range(Cells(1, 2), Cells(numRows, 2)), Type:=xlFillDefault

    Thank you in advance for any help!

    • Report Content
  • Carim
    OzMVP (0007*2) - 4
    Likes Received
    846
    Points
    21,253
    Trophies
    2
    Posts
    6,761
    • Feb 11th 2021
    • #2

    Hello and Welcome to the Forum :)


    You could test the following

    Code
    1. Sub MultTest()
    2. Dim last As Long
    3. last = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
    4. Range("B1:B" & last).FormulaR1C1 = "=RC[-1]*R1C4"
    5. End Sub

    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

    • Report Content
  • royUK
    Super Moderator
    Likes Received
    556
    Points
    74,761
    Trophies
    2
    Posts
    24,665
    • Feb 11th 2021
    • #3

    I can't see any reason to use VBA for this. A formula would be more efficient.

    Hope that Helps


    Roy


    New users should read the Forum Rules before posting


    For free Excel tools & articles visit my web site


    Check out my new web site.


    royUK's Database Form


    Where to paste code from the Forum


    About me.

    • Report Content

Share

  • Facebook
  • Twitter
  • Reddit
  • WhatsApp
  • LinkedIn

Similar Threads

  • Insert multiple blanc Columns Between Columns with data.

    • dilshod_k
    • Dec 28th 2020
    • Excel VBA / Macros
  • Routine loops through files in folder, progressively slows down resulting in workbook crash.

    • dilshod_k
    • Dec 13th 2020
    • Excel VBA / Macros
  • Loop through workbooks in a folder, with progress bar.

    • dilshod_k
    • Dec 12th 2020
    • Excel VBA / Macros
  • Autofill formula one table column to the right

    • DebugMe
    • Jul 2nd 2020
    • Excel VBA / Macros
  • Autocomplete from list on another sheet

    • Chrischris
    • Mar 11th 2020
    • Excel General
  1. Privacy Policy
  2. Contact
© OzGrid Business Services. All Rights reserved.
  1. Navigation
  2. OzGrid
    1. Excel/VBA Consultancy
    2. OzGrid Store
    3. Training
    4. Freebies
  3. Forum
    1. Unresolved Threads
    2. Forum Rules
  4. Dashboard
  5. Articles
  6. Members
    1. Recent Activities
    2. Users Online
    3. Team
    4. Search Members
  7. Search
  8. Options
    1. (placeholder)
  9. Current Location
  10. OzGrid Free Excel/VBA Help Forum
  11. HELP FORUMS
  12. Excel General
  1. User Menu
  2. Login
  3. Registration
This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close