RedditPP Mascot

RedditPP

r/vba • … • u/herregudo

Removing values in cells throughout the spreadsheet based on another value

I guess the topic headline is kinda confusing.

Anyway, I have a lot of large datasets in excel containing the ask price, bid price and the spread for a range of stocks for a range of countries.

The thing is, that since the dataset dates all the way back to 1991, I've come over a lot bad data, giving the spread a value of either -2 or 2. The reason for this is that the value for either the ask or bid price is missing. Up until now, I've tried removing this manually (bad idea, I know). I was then wondering if anyone of you knew a way to ease up the workload by using a sub to basically remove the values in the two cells to the left, namely the ask and bid price, when encountering the value of 2/-2 in the column for spread.

As of now, my spreadsheet has this in the top row:

Date-Ask-Bid-Spread-Ask-Bid-Spread-Ask-Bid-Spread...etc

Any help is appreciated! I'm extremely green when it comes to VBA, so if you got any questions, go ahead.

— 0