LOOP

gronkette1

Board Regular
Joined
Mar 12, 2002
Messages
90
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!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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
 
Upvote 0
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))
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,337
Members
448,568
Latest member
Honeymonster123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top