+ Reply to Thread
Results 1 to 4 of 4

Using excel vba to create an if formula with variable columns

  1. #1
    Registered User
    Join Date
    12-05-2019
    Location
    bournemouth
    MS-Off Ver
    2016
    Posts
    2

    Using excel vba to create an if formula with variable columns

    Hi

    i am trying to write a macro that will sort two columns. In order to so I must compare cell a10 with cell e10 (this cell might be another column depending on width of first column). So, i need the formula to be able to reflect what the cell reference is. I have in cell c3 what this should be so in this example it is the letter e

    I have tried ActiveCell.FormulaR1C1 = "=IF(RC[-8]=RC[-4],""OK"",""problem"")" but when i put a variable (that I know) instead of the 8 or 4 it wont work/

    Any help appreciated


  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Using excel vba to create an if formula with variable columns

    You could do it without using a formula

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    12-05-2019
    Location
    bournemouth
    MS-Off Ver
    2016
    Posts
    2

    Re: Using excel vba to create an if formula with variable columns

    Wow, excellent. Thanks so much. It had never occurred to me to use a loop. I have waster so much time and your solution is so elegant

    Once again, thanks

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Using excel vba to create an if formula with variable columns

    Quote Originally Posted by adles View Post
    Wow, excellent. Thanks so much. It had never occurred to me to use a loop. I have waster so much time and your solution is so elegant

    Once again, thanks
    You are welcome,
    regards, JLG

+ 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. [SOLVED] Macro to create columns by referencing a variable column
    By mactoolsix in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-11-2014, 05:19 PM
  2. Replies: 2
    Last Post: 07-18-2012, 07:45 AM
  3. Create 2 columns and populate variable data combinations
    By Pete123abc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-18-2011, 12:35 PM
  4. Create Summary from multiple sheets with variable columns
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2011, 02:31 PM
  5. RE: how do I create a formula in excel with using 2 columns of info?
    By Sloth in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-17-2006, 03:40 PM
  6. RE: how do I create a formula in excel with using 2 columns of info?
    By Toppers in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-17-2006, 03:40 PM
  7. how do I create a formula in excel with using 2 columns of info?
    By Valerie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-17-2006, 03:40 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