Copying formula to the last active row

NoxGalleon106

New Member
Joined
Oct 15, 2016
Messages
28
Hi,

I have a formula in B2 that i want to drag up to the last row that has a value in column C.

Formula is:
= if(D2=“BOAUSD”, “NY to advise”, IF (D2= “TDTOR”, “Toronto to advise”, “London to advise”))

When I drag to the next row, the cell should change to D4,D5 etc.
 

NoxGalleon106

New Member
Joined
Oct 15, 2016
Messages
28
it does for me, do you have filters in place?
Hi, there are no filters.can you help me with the correct VBA code to execute the scenario I have described? The formula is in B2 and should be drag up to the last row where there is value in column C.
 

mole999

Moderator
Joined
Oct 23, 2004
Messages
9,899
when you said drag I assumed you would do it manually

Code:
 Sub Macro1()
    Dim LastRow As Long
    LastRow = ActiveSheet.Range("C100000").End(xlUp).Row
    Range("B2").FormulaR1C1 = _
        "=IF(RC[2]=""BOAUSD"",""NY to advise"",IF(RC[2]=""TDTOR"",""Toronto to advise"",""London to advise""))"
    Range("B2").Select
    Selection.AutoFill Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault
    Range("B2:B" & LastRow).Select
End Sub
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,487
Office Version
365, 2010
Platform
Windows, Mobile
@NoxGalleon106, you apply the formula directly to the range without filling/copying (Excel is intelligent enough to increment the rows).

Code:
Sub FillFormula()
Range("B2:B" & Range("C" & Rows.Count).End(xlUp).Row).Formula = "=IF(D2=""BOAUSD2"", ""NY to advise"", IF(D2= ""TDTOR"", ""Toronto to advise"", ""London to advise""))"
End Sub
 

Forum statistics

Threads
1,081,973
Messages
5,362,505
Members
400,677
Latest member
champchamp

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top