Consulting

Results 1 to 4 of 4

Thread: Drag a formula down to the end of a list

  1. #1
    VBAX Regular
    Joined
    Apr 2015
    Location
    Paris
    Posts
    13
    Location

    Drag a formula down to the end of a list

    Hi,

    I have this formula :

    Range("I3").Formula = "=IF(C3=C2,0,1)"

    How can I drag it down to automatically fill all the cells until the last row?

    The number of rows I have differs weekly so I need to get a code that drags the formula down automatically to the last cell on the list.

    Any help will be appreciated

    Thank you.

    Chris

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    try:

    With Worksheets("Sheet1") 'change workheet name to suit
        LastRow = .Range("C" & .Rows.Count).End(xlUp).Row
        .Range("I3:I" & LastRow).Formula = "=IF(C3=C2,0,1)"
    End With
    or, without using a variable
    With Worksheets("Sheet1") 'change workheet name to suit
        .Range("I3:I" & .Range("C" & .Rows.Count).End(xlUp).Row).Formula = "=IF(C3=C2,0,1)"
    End With
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    You don't need to if you use the Table /Listobject (Excel >2003)

  4. #4
    VBAX Regular
    Joined
    Apr 2015
    Location
    Paris
    Posts
    13
    Location
    Thank you so much!! It works

Posting Permissions

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