Power Query Course in Spanish
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: LOOP

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Jackson, MI
    Posts
    90
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have the following:

    AEP 28.92
    DEL 28.00
    ATSI 0 30.57

    I need a DO LOOP that will look at column A, if the value in A is "AEP or DEL" put the value of B in a new column; if value in A is "ATSI" put the value of column C into the same column.

    Thanks a heap!

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Perth Australia
    Posts
    1,584
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi gronkette1

    You could try this code, it puts the data into column F (represented by 5 in the offset statements - change the 5 to the column number you want)

    For Each cell In Range("A:A")
    If cell.Value = "AEP" Or cell.Value = "DEL" Then
    cell.Offset(0, 5).Value = cell.Offset(0, 1).Value
    Else
    If cell.Value = "ATSI" Then
    cell.Offset(0, 5).Value = cell.Offset(0, 2).Value
    End If
    End If
    Next
    End Sub

    Hope this helps
    regards
    Derek

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Jackson, MI
    Posts
    90
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    thanks....

    I give it a try.

  4. #4
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You don't need to do this in a macro.

    Put this formula in column D or whichever you want:

    =IF(OR(A:A="AEP",A:A="DEL")=TRUE,B:B,IF(A:A="ATSI",C:C))
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Location
    Jackson, MI
    Posts
    90
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Works GREAT !!!

    Thanks again.....

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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