Change range to incorporate multiple columns (not adjacent), VBA/Macro

Copper Contributor

Hi all,

 

Been playing and struggling with this for some time now. I have created the following code for a Macro, and although I have it working for 1 column, I'm not sure how to change it to have multiple. I have tried doing "K,S,V" etc and "$K,$S,$V" and other variables and I can't get it to play correctly.

 

the code I have atm is;

Sub Auto_open()
   Dim r As Long
   Dim Msg As String
   With Sheets("Data")
       For r = 2 To 5000
           If .Range("K" & r).Value > 0 And .Range("AB1").Value > .Range("K" & r).Value Then
               Msg = Msg & vbLf & .Range("B" & r).Value & " requires at least one review"

           End If
       Next r
   End With
   MsgBox Msg
End Sub

- At the moment the range is set to column "K", I need it to read/recognise Columns, "K, S, V, X and AA".

- I'm not sure if the "r" is something I still need, or if it will automatically recognise it as a column.

- "AB1" is just a cell I put "=Today()" in as I need it to be working off todays date, and I wasn't sure how to get it to recognise it without a reference cell.

- All of these will eventually need to  be working out that "AC" is not equal to "Closed" so if "Closed" it doesn't look at any dates.

 

0 Replies