+ Reply to Thread
Results 1 to 2 of 2

Applying IF logic as VBA down whole column for 5000 rows

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Applying IF logic as VBA down whole column for 5000 rows

    Hello friends,

    I need to apply what would be 10 convoluted IF statements to a whole column using VBA.

    Situations is that I need to return (in column P) a concatenation of column D & " & " & column C's adjacent cells if each cell of column A is equal to up to 10 rows below (up to 5000 rows). Confused?!

    Well If I was to write this in formula it would look like this:

    =IF(ISBLANK(A2),""&
    IF(A2=A11,C11&"X "&D11&" & "&C10&"X "&D10&" & "&C9&"X "&D9&" & "&C8&"X "&D8&" & "& C7&"X "&D7&" & "&C6&"X "&D6&" & "&C5&"X "&D5&" & "&" & "&C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2,
    IF(A2=A10,C10&"X "&D10&" & "&C9&"X "&D9&" & "&C8&"X "&D8&" & "& C7&"X "&D7&" & "&C6&"X "&D6&" & "&C5&"X "&D5&" & "&" & "&C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2,
    IF(A2=A9, C9&"X "&D9&" & "&C8&"X "&D8&" & "& C7&"X "&D7&" & "&C6&"X "&D6&" & "&C5&"X "&D5&" & "&" & "&C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2,
    IF(A2=A8,C8&"X "&D8&" & "&C7&"X "&D7&" & "&C6&"X "&D6&" & "&C5&"X "&D5&" & "&" & "&C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2,
    IF(A2=A7,C7&"X "&D7&" & "&C6&"X "&D6&" & "&C5&"X "&D5&" & "&" & "&C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2,
    IF(A2=A6,C6&"X "&D6&" & "&C5&"X "&D5&" & "&" & "&C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2,
    IF(A2=A5,C5&"X "&D5&" & "&" & "&C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2,
    IF(A2=A4,C4&"X "&D4&" & "&C3&"X "&D3&" & "&C2&"X "&D2&
    IF(A2=A3,C3&"X "&D3&" & "&C2&"X "&D2,C2&"X "&D2))))))))))

    As I am not great with VBA but I need this done in a macro I was hoping someone can show me how it would be done as this code does not work when it is converted to VBA but does work as a formula.

    Thanks,
    Brendan

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,855

    Re: Applying IF logic as VBA down whole column for 5000 rows

    Instead of trying to unconvolute your formula, why not explain in simple English exactly what you are attempting to do. It is easier to understand and ensures we know exactly what you want.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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] Formula for taking 10% of amount and if > 5000 = 500 or if < 5000 = the 10%
    By Vicious00013 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-28-2016, 05:20 PM
  2. Applying formula in a column for new rows inserted ?
    By andyzz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-23-2014, 05:26 AM
  3. [SOLVED] Loop specific VBA code for every 15 Rows upto 5000 rows of a sheet
    By Narasimharao Nandula in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-26-2013, 08:48 AM
  4. Copying and pasting repeatly over 5000 rows (Macro).
    By GregOgie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2012, 06:57 PM
  5. Consolidating 12 worksheets with 5000+ rows in each
    By MARKSTRO in forum Excel General
    Replies: 2
    Last Post: 03-13-2012, 06:49 PM
  6. Replies: 6
    Last Post: 02-16-2012, 04:52 PM
  7. 5000 rows in vlookup
    By jabran in forum Excel General
    Replies: 1
    Last Post: 06-26-2007, 11:25 AM

Tags for this Thread

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