Looping Until the adjacent column has a certain value in it. Please help

chasin

New Member
Joined
Jul 7, 2011
Messages
2
I'm in the process of creating a macro, but there is a step which I'm stuck at. I have a macro that contains large lists

column A:Stock symbol, column B: ex-dividend date of each symbol, column C: dividend, column D:today's date, column E: matches between column's B and D (Date only), otherwise it lists 0's.

I chose to turn the dates into serial numbers and sort them from furthest off into the future to present. In column E there ends up being a list (all the same date) whose ex-div date matches tommorrow's date, after there are no more matches the rest of the column is zero's to the bottom of the list. This way I'm aware of all the symbols in my universe that pay a dividend the following day. I need help in the next column of code. I want there to be a loop in column F. In this loop I would like there to be an "if" condition such as =If(E2=B2, CONCATENATE(A2, "", C2, ""), "0"). I would like it to run this code until there is a zero column E (i.e. there are no more ex div dates that match my symbols). I'm thinking this would be loop such as

Dim somevariable AS variant
Dim somevariable As Integer

somevariable = .....

Do

....

Loop Until ActiveCell.Offset(0,-1) = 0

or soemthing like this. I can't figure it out though and need some help. Any help would be greatly appreciated thanks.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,

Would you like to post a sample of some data showing just what you are looking for?

I'm afraid that I didn't find your verbal description very illuminating.
 
Upvote 0
moz-screenshot-3.png
I will try to clean that up a bit. That must not be too clear at all upon second glance. Let's pretend that on a particular sheet I'm working on there are is only one column of data. We'll call it column A. Column A is composed completely of 1's or 0's in no particular order at first. However, I decide to sort these 1's and 0's in column A in descending order from greatest to smallest. So at some point we will run into a row where we switch from 1's to 0's in this new sorted arrangement in column A. I want to run a macro in column B that will display a "1" in any cell in column B which is adjacent to a "1" in column A. So basically it will display what is in the adjacent cell again. However, once it gets to a row in which there is a "0" in column A, I want the loop to stop running.

Does that make a little better sense? Sorry that original one was so unclear.
 
Upvote 0
moz-screenshot-3.png

Does that make a little better sense?
For some reason I can't see that file from your C:\Users folder. Did you turn your PC off?

Try placing borders around the worksheet cells, selecting a small font such as 8pt or 9pt, then then copy-paste the cells into a message.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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