VBA code to copy/paste data in adjacent cell when the column of cells have a specific value

Mothi

New Member
Joined
Mar 21, 2018
Messages
2
I would like to ask the community for a way for me to VBA code my sheet 'macro' to look at all the '0' value cells in column B. Then copy the adjacent cells in column C and past in Column D.
This would help me to separate all the zero return stocks from the positive and negative returns. The problem I face is that the zero return stocks will later be sorted by returns and these zero returns are messing with my VLOOKUP to identify the stock code later on.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
Public Sub aMacro1()
Range("B2").Select
While ActiveCell.Value <> ""
   If ActiveCell.Value = 0 Then
      ActiveCell.Offset(0, 2).Value = ActiveCell.Offset(0, 1).Value
   End If
   
   ActiveCell.Offset(1, 0).Select   'next row
Wend
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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