So basically I have some code which looks up an inputted date, and then if found, uses this reference point to get other values in the same row and then populates another sheet with this data.
It loops through this until no new instances of the date value are found.
This is the code
I can place an if statement around the 'perform actions' part of the code, which say only do if rng.offset(,-19) = "A" for instance (based on an input)
However I have a listbox which specifies the value "A" and this may be more than 1 selection. So I have no idea how to reference the value of the selections, and say if rng.offset(,-19) = "A" or "B" or "C" for instance.
Have been stuck on this for a while, and can't get it to go, so any help would be really appreciated.
It loops through this until no new instances of the date value are found.
This is the code
Rich (BB code):
Dim rng As Range, _
rng1 As String, _
WeekStart As Date, _
ws1 As Worksheet, _
ws2 As Worksheet, _
findoffset As Long, _
lngLastRow As Long, _
DT As Date
DT = CDate(txtSetDate.Value)
lngLastRow = Sheets("Sheet1").Cells(Rows.Count, "BS").End(xlUp).Row
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Weekly")
WeekStart = DT - (Weekday(DT, 3))
MsgBox WeekStart
ws1.Unprotect "Password"
findoffset = 0
With ws1.Range("BS3:BS" & lngLastRow)
Set rng = .Find(WeekStart, LookIn:=xlValues)
If Not rng Is Nothing Then
rng1 = rng.Address
Do
'PerformActions'
findoffset = findoffset + 1
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.Address <> rng1
End If
End With
I can place an if statement around the 'perform actions' part of the code, which say only do if rng.offset(,-19) = "A" for instance (based on an input)
However I have a listbox which specifies the value "A" and this may be more than 1 selection. So I have no idea how to reference the value of the selections, and say if rng.offset(,-19) = "A" or "B" or "C" for instance.
Have been stuck on this for a while, and can't get it to go, so any help would be really appreciated.