+ Reply to Thread
Results 1 to 3 of 3

Variable (row number) in IF formula in macro

  1. #1
    Registered User
    Join Date
    11-04-2013
    Location
    UK
    MS-Off Ver
    2016 (Office 365 Business Premium)
    Posts
    7

    Variable (row number) in IF formula in macro

    Version: Excel 2016

    Hi there,

    I can't figure how to include a variable row number in an IF formula.

    I use this to get the last row in OtherFile|Sheet1 and create variable LastRow.
    Please Login or Register  to view this content.
    I then want create an IF formula in the current cell. The IF formula says "if B2 is > the last B cell in OtherFile.xlsx|Sheet1, then return 'New', otherwise; 'Old'".
    Please Login or Register  to view this content.
    So essentially I want a formula that would replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Any pointers would be much appreciated!

    Thanks.

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Variable (row number) in IF formula in macro

    Generally, the rule is to break the quotation, insert your variable with ampersands, then resume the quotations, so try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-04-2013
    Location
    UK
    MS-Off Ver
    2016 (Office 365 Business Premium)
    Posts
    7

    Re: Variable (row number) in IF formula in macro

    Perfect; that worked! Thank you so much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to cut and paste a variable number of rows to a variable location?
    By TheClaw2323 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-03-2015, 07:57 AM
  2. Macro to insert a variable number of rows into a variable location
    By TheClaw2323 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2015, 05:31 AM
  3. [SOLVED] Calculate average of variable number of cells variable number of times
    By WeirnetherlandsBart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2014, 10:11 AM
  4. Variable number of rows in a macro
    By CrazyHorse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2011, 09:26 AM
  5. Macro with variable number of rows
    By Jonlew in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-11-2011, 01:01 PM
  6. Assigning a Row Number to a variable in a macro
    By Neil07979 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-19-2009, 08:17 AM
  7. a macro that uses a variable serial number
    By BusDriver2 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 10-06-2008, 03:06 PM

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