djburnheim
Technical User
I'm trying to write a procedure that finds a cell in a sheet then gets the value from the cell under it and depending on that value does something...I have basically got it working but am running into problems I think because of the data types...any suggestions would be great.
Dave
***code***
Dim Rota
Dim StartDate As String
Dim Team1 As Range
Dim Team2 As Range
Dim Team3 As Range
Set Team1 = WorkSheets("Weekly Stats"
.Range("C6, C9, C11"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set Team2 = WorkSheets("Weekly Stats"
.Range("C7, C8, C12"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set Team3 = WorkSheets("Weekly Stats"
.Range("C10, C13, C14"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
StartDate = Format(WorkSheets("Weekly Stats"
.Range("D4"
.Value, "dd-MMM"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
With Worksheets("Rota"
.Range("a1:f100"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set DCell = .Find(StartDate)
If Not DCell Is Nothing Then
DRow = DCell.Row + 1
DColumn = DCell.Column
Rota = Cells(DRow, DColumn).Value
End If
If Rota = "1" Then
Team1.Select
Team1.Activate
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Team2.Select
Team2.Activate
With Selection.Interior
.ColorIndex = 8
.Pattern = xlSolid
End With
Team3.Select
Team3.Activate
With Selection.Interior
.ColorIndex = 7
.Pattern = xlSolid
End With
End If
Dave
***code***
Dim Rota
Dim StartDate As String
Dim Team1 As Range
Dim Team2 As Range
Dim Team3 As Range
Set Team1 = WorkSheets("Weekly Stats"
Set Team2 = WorkSheets("Weekly Stats"
Set Team3 = WorkSheets("Weekly Stats"
StartDate = Format(WorkSheets("Weekly Stats"
With Worksheets("Rota"
Set DCell = .Find(StartDate)
If Not DCell Is Nothing Then
DRow = DCell.Row + 1
DColumn = DCell.Column
Rota = Cells(DRow, DColumn).Value
End If
If Rota = "1" Then
Team1.Select
Team1.Activate
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Team2.Select
Team2.Activate
With Selection.Interior
.ColorIndex = 8
.Pattern = xlSolid
End With
Team3.Select
Team3.Activate
With Selection.Interior
.ColorIndex = 7
.Pattern = xlSolid
End With
End If