Trouble highlighting row data.

Davio

New Member
Joined
Jun 10, 2014
Messages
36
TABLE1JANUARY
12345678910
TEAM1XXXXX
TEAM2XXXXX
TEAM3XX

<tbody>
</tbody>

TABLE2TASKSTART DATEEND DATE
TEAM1Y1jan3jan
TEAM2X3jan7jan
TEAM3B9jan10jan
TEAM1X7jan8jan

<tbody>
</tbody>
I am having issues with TABLE1 highlighting the start and end dates from TABLE2. My goal is to have the data from TABLE2 visualized in TABLE1 The task data does not factor in to the visualization represented in TABLE1. any help or advice is appreciated.

Thank you.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBY
1
2SunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFri
31-Sep-192-Sep-193-Sep-194-Sep-195-Sep-196-Sep-197-Sep-198-Sep-199-Sep-1910-Sep-1911-Sep-1912-Sep-1913-Sep-1914-Sep-1915-Sep-1916-Sep-1917-Sep-1918-Sep-1919-Sep-1920-Sep-1921-Sep-1922-Sep-1923-Sep-1924-Sep-1925-Sep-1926-Sep-1927-Sep-1928-Sep-1929-Sep-1930-Sep-191-Oct-192-Oct-193-Oct-194-Oct-195-Oct-196-Oct-197-Oct-198-Oct-199-Oct-1910-Oct-1911-Oct-1912-Oct-1913-Oct-1914-Oct-1915-Oct-1916-Oct-1917-Oct-1918-Oct-1919-Oct-1920-Oct-1921-Oct-1922-Oct-1923-Oct-1924-Oct-1925-Oct-1926-Oct-1927-Oct-1928-Oct-1929-Oct-1930-Oct-1931-Oct-191-Nov-192-Nov-193-Nov-194-Nov-195-Nov-196-Nov-197-Nov-198-Nov-199-Nov-1910-Nov-1911-Nov-1912-Nov-1913-Nov-1914-Nov-1915-Nov-19
4TEAM1
5TEAM2
6TEAM3
7TEAM4
8TEAM5
9TEAM6
10MISC EVENTS
11Report PeriodSep-19Oct-19Nov-19
12
13
14
15
16
17
18TEAMPROJECTSTART DATEEND DATE
19TEAM1CROSSFIT3-Sep-1910-Oct-19
20TEAM2STRENGTH TNG10-Sep-1915-Oct-19
21TEAM3CARDIO1-Oct-1920-Oct-19
22TEAM4NUTRITION30-Oct-1910-Nov-19
23TEAM510-Nov-1912-Nov-19
24TEAM615-Nov-1919-Nov-19
25MISC EVENTS10-Sep-193-Nov-19
26
27
28
29
30
31
32
33
TRAINING



Peter,

Looking at the tracker, I think it will be better if I have the "projects" displayed across the date range. I have no experience with vba or macros. Where do I begin?
 
Upvote 0
Looking at the tracker, I think it will be better if I have the "projects" displayed across the date range. I have no experience with vba or macros. Where do I begin?
For the layout you have just posted, try this in a copy of the workbook. It is a Worksheet_Change event code which means it is triggered when you change anything on the worksheet. It looks (or should) to see if anything was changed in that bottom section (below the 'Team Name' heading in A18) & if so rebuilds the top tracker section. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test. (To start with copy the bottom section and re-paste it to trigger the code. Then try adding/deleting/altering dates, team names Projects etc)
4. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm).

The colours that get applied to each team are determined by the 'Const' line near the start of the code and the choice of colours can be seen here

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, rw As Range, cellTeam As Range, rAnchorDate As Range, rTracker As Range, rData As Range
  Dim rwTeam As Long, NumDays As Long, TeamClr As Long, AnchorDate As Long, AnchorCol As Long, StartDateCol As Long, oSet As Long, lc As Long
  Dim TeamName As String
  Dim aColours As Variant
  
  Const TeamColours As String = "$Team1:50|$TEAM2:4|$Team3:33|$TEAM4:6|$TEAM5:22|$Team6:45|$Misc Events:35" '<- Adjust team names and colour values here

  Set rData = Columns("A").Find(What:="Team Name", LookAt:=xlWhole, SearchDirection:=xlPrevious, MatchCase:=False).Offset(1)
  Set rData = rData.Resize(Cells.SpecialCells(xlCellTypeLastCell).Row - rData.Row + 1, 7)
  Set Changed = Intersect(Target, rData)
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    On Error GoTo AEET
    lc = Cells(3, Columns.Count).End(xlToLeft).Column
    Set rTracker = Range("B4").Resize(Columns("A").Find(What:="Report Period", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlPrevious, MatchCase:=False).Row - 4, lc - 1)
    Set rAnchorDate = rTracker.Cells(0, 1)
    AnchorDate = rAnchorDate.Value
    AnchorCol = rAnchorDate.Column
    aColours = Split(TeamColours, "|")
    With rTracker
      .ClearContents
      .Interior.ColorIndex = xlNone
      .HorizontalAlignment = xlGeneral
    End With
    For Each rw In rData.Rows
      TeamName = rw.Cells(1).Value
      If Len(TeamName) > 0 Then
        Set cellTeam = Range("A4:A17").Find(What:=TeamName, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
        If Not cellTeam Is Nothing Then
          rwTeam = cellTeam.Row
          
          NumDays = rw.Cells(7).Value - rw.Cells(6).Value + 1
          oSet = rw.Cells(6).Value - AnchorDate
          StartDateCol = AnchorCol + oSet
          With Cells(rwTeam, StartDateCol).Resize(, NumDays)
            .Cells(1).Value = rw.Cells(2).Value
            .HorizontalAlignment = xlCenterAcrossSelection
            If InStr(1, TeamColours, "$" & TeamName & ":", vbTextCompare) > 0 Then
               TeamClr = Split(Mid(TeamColours, InStr(1, TeamColours, "$" & TeamName & ":", vbTextCompare) + Len(TeamName) + 2), "|")(0)
               .Interior.ColorIndex = TeamClr
            End If
          End With
        End If
      End If
    Next rw
  End If
AEET:
  Application.EnableEvents = True
End Sub

Here is part of my sheet after I have entered my data at the bottom. Note that I have changed that data so you can see the results in a screen shot that is not too large.

Excel Workbook
ABCDEFGHIJKLMNOPQ
301-Sep-1902-Sep-1903-Sep-1904-Sep-1905-Sep-1906-Sep-1907-Sep-1908-Sep-1909-Sep-1910-Sep-1911-Sep-1912-Sep-1913-Sep-1914-Sep-1915-Sep-1916-Sep-19
4TEAM1CROSSFIT
5TEAM2STRENGTH TNG
6TEAM3CARDIONUTRITION
7TEAM4
8TEAM5
9TEAM6Other 1
10MISC EVENTSOther 2
11Report Period
12
16
17
18Team NameProjectSTART DATEEND DATE
19TEAM1CROSSFIT1-Sep8-Sep
20TEAM2STRENGTH TNG10-Sep15-Sep
21TEAM3CARDIO2-Sep5-Sep
22TEAM3NUTRITION9-Sep15-Sep
23TEAM44-Sep7-Sep
24TEAM6Other 17-Sep16-Sep
25MISC EVENTSOther 210-Sep10-Sep
26
Tables (wsc1)
 
Last edited:
Upvote 0
After following the instructions, there are no changes.

Disregard,

It works perfectly. Thank you
 
Last edited:
Upvote 0
Peter,

I am trying to update the spreadsheet to compile all information to display the ranges on a summary page.

So far, I've made duplicate sheets with different tab (Name A, Name B, Name C, Name D, Name E, Name F, Name G) names. Now I want only the calendar section from each sheet (tab) to display into one summary calendar. I have adjusted some of the team names to reflect which tab they are pulled from.
 
Upvote 0
Peter,

I am trying to update the spreadsheet to compile all information to display the ranges on a summary page.

So far, I've made duplicate sheets with different tab (Name A, Name B, Name C, Name D, Name E, Name F, Name G) names. Now I want only the calendar section from each sheet (tab) to display into one summary calendar. I have adjusted some of the team names to reflect which tab they are pulled from.
Sorry, I don't understand exactly what your setup & requirement is. Perhaps you could post some very small examples & results to help demonstrate?
 
Upvote 0
ABCDEFGHIJKLMNOP
2SunMonTueWedThuFriSatSunMonTueWedThuFriSatSun
31-Sep-192-Sep-193-Sep-194-Sep-195-Sep-196-Sep-197-Sep-198-Sep-199-Sep-1910-Sep-1911-Sep-1912-Sep-1913-Sep-1914-Sep-1915-Sep-19
4TEAM-1STRENGTH
5TEAM-2
6TEAM-3
7TEAM-4VACATION-VACANT
8TEAM-5NO TRAINER AVAILABLE
9MISC EVENTS
10Report PeriodSep-19
11
12
13
14
15
16
17TEAM NAMETRAININGSTARTEND
18TEAM-1STRENGTH10-Sep-1920-Sep-19
19TEAM-2CARDIO25-Sep-192-Oct-19
20TEAM-3ENDURANCE7-Oct-1915-Oct-19
21TEAM-4VACATION-VACANT10-Sep-1910-Oct-19
22TEAM-5NO TRAINER AVAILABLE1-Sep-1922-Oct-19
23MISC EVENTSHALLOWEEN SPECIAL25-Oct-1931-Oct-19
24TEAM-1ENDURANCE7-Oct-1915-Oct-19
25TEAM-2STRENGTH19-Oct-1929-Oct-19

<tbody>
</tbody>
TABLE 1 TAB (NAME A)



VBA Code 1
-----------------------------------------------------------------

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range, rw As Range, cellTeam As Range, rAnchorDate As Range, rTracker As Range, rData As Range
Dim rwTeam As Long, NumDays As Long, TeamClr As Long, AnchorDate As Long, AnchorCol As Long, StartDateCol As Long, oSet As Long, lc As Long
Dim TeamName As String
Dim aColours As Variant

Const TeamColours As String = "$TEAM-1:50|$TEAM-2:4|$TEAM-3:33|$TEAM-4:6|$TEAM-5:22|$TEAM-6:45|$Misc Events:35" '<- Adjust team names and colour values here

Set rData = Columns("A").Find(What:="Team Name", LookAt:=xlWhole, SearchDirection:=xlPrevious, MatchCase:=False).Offset(1)
Set rData = rData.Resize(Cells.SpecialCells(xlCellTypeLastCell).Row - rData.Row + 1, 9)
Set Changed = Intersect(Target, rData)
If Not Changed Is Nothing Then
Application.EnableEvents = False
On Error GoTo AEET
lc = Cells(3, Columns.Count).End(xlToLeft).Column
Set rTracker = Range("B4").Resize(Columns("A").Find(What:="Report Period", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlPrevious, MatchCase:=False).Row - 4, lc - 1)
Set rAnchorDate = rTracker.Cells(0, 1)
AnchorDate = rAnchorDate.Value
AnchorCol = rAnchorDate.Column
aColours = Split(TeamColours, "|")
With rTracker
.ClearContents
.Interior.ColorIndex = xlNone
.HorizontalAlignment = xlGeneral
End With
For Each rw In rData.Rows
TeamName = rw.Cells(1).Value
If Len(TeamName) > 0 Then
Set cellTeam = Range("A4:A10").Find(What:=TeamName, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not cellTeam Is Nothing Then
rwTeam = cellTeam.Row

NumDays = rw.Cells(9).Value - rw.Cells(6).Value + 1
oSet = rw.Cells(6).Value - AnchorDate
StartDateCol = AnchorCol + oSet
With Cells(rwTeam, StartDateCol).Resize(, NumDays)
.Cells(1).Value = rw.Cells(2).Value
.HorizontalAlignment = xlCenterAcrossSelection
If InStr(1, TeamColours, "$" & TeamName & ":", vbTextCompare) > 0 Then
TeamClr = Split(Mid(TeamColours, InStr(1, TeamColours, "$" & TeamName & ":", vbTextCompare) + Len(TeamName) + 2), "|")(0)
.Interior.ColorIndex = TeamClr
End If
End With
End If
End If
Next rw
End If
AEET:
Application.EnableEvents = True

--------------------------------------



TABLE 2:


ABCDEFGHIJKLMNOP
1Report PeriodSep-19
22019-2020SunMonTueWedThuFriSatSunMonTueWedThuFriSatSun
31-Sep-192-Sep-193-Sep-194-Sep-195-Sep-196-Sep-197-Sep-198-Sep-199-Sep-1910-Sep-1911-Sep-1912-Sep-1913-Sep-1914-Sep-1915-Sep-19
4NAME A
5
6
7
8
9
10
11NAME B
12
13
14
15
16
17
18NAME C
19
20
21
22
23
24
25NAME D
26
27
28
29
30

<tbody>
</tbody>
SUMMARY SHEET

TABLE 1 shows one of seven duplicate tabs which shows each coach's team schedule. Each tab also has the VBA code included above. My goal is to have the tab name and calendar portion of each coach's tab populate on one summary sheet as in TABLE 2. NAME A is merged from A4:A9, NAME B A11:A16, NAME C A18:A23, etc. I hope this clears thing up a bit.
 
Upvote 0
Sorry, I'm afraid I still don't "get it" so am unable to advise further.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top