Hi Guys,
The following vba code runs when the user clicks the command button. It first calculates the CurrentWk and then searches the range c for the resulting value. I want the macro to run through each cell in the range c and exit the loop once c.value = CurrentWk.
Can anyone assist?
Private Sub cmdForecast_Click()
Dim CurrentWk As Integer
Dim Age As Integer
Dim r As Integer
Dim c As Range
'Go to 12-Week Forecast sheet
Sheets("12-Week Forecast").Select
ActiveSheet.Range("G3").Select
Age = 13
'Calculate Current Week
CurrentWk = ActiveSheet.Range("G3").Value - Age
'Get Final Row
r = Cells(Rows.Count, 1).End(xlUp).Row
Do
For Each c In Range("A5:A" & r)
If c.Value = CurrentWk Then
'Select range going down 15 rows
c.Select
End If
Next c
Loop Until c.Value = CurrentWk
End Sub
Bookmarks