Hello Fellow member,
I'm trying to create my own dashboard to visualize the progress of each shipping project.
On C-Z column, I'm going to manually insert date at each check point, and cells underneath date (starting from AA column) head would then be color-filled.
I want to make progress displays to automatically move to date to match with "C5" cell entry, which will be today's date. I used VBA code as below, but it didn't work.
I freeze "AA8" panes where all date heads begin.
Can anyone help to fix error in following code?
Sub Date_Search()
' Find the last column number in row 7.
Dim endCol As Long
Dim startcell As Range
Dim sht As Worksheet
Set sht = Sheets("schedule")
Set startcell = sht.Range("AA7").Address
endCol = sht.Cells(7, Columns.Count).End(xlToLeft).Column
' Find the value you are looking for
Set lookupvalue = sht.Range("C5").Value
' Select the range you are looking in
Set lookuprange = sht.Range(startcell, sht.Cells(7, endCol).Address).Select
' Find the first matching value, and return the row number
FirstMatchColumnNumber = WorksheetFunction.Match(lookupvalue, lookuprange, 0)
' Go to the applicable row.
sht.Range(8, FirstMatchColumnNumber).Select
End Sub
I'm trying to create my own dashboard to visualize the progress of each shipping project.
On C-Z column, I'm going to manually insert date at each check point, and cells underneath date (starting from AA column) head would then be color-filled.
I want to make progress displays to automatically move to date to match with "C5" cell entry, which will be today's date. I used VBA code as below, but it didn't work.
I freeze "AA8" panes where all date heads begin.
Can anyone help to fix error in following code?
Sub Date_Search()
' Find the last column number in row 7.
Dim endCol As Long
Dim startcell As Range
Dim sht As Worksheet
Set sht = Sheets("schedule")
Set startcell = sht.Range("AA7").Address
endCol = sht.Cells(7, Columns.Count).End(xlToLeft).Column
' Find the value you are looking for
Set lookupvalue = sht.Range("C5").Value
' Select the range you are looking in
Set lookuprange = sht.Range(startcell, sht.Cells(7, endCol).Address).Select
' Find the first matching value, and return the row number
FirstMatchColumnNumber = WorksheetFunction.Match(lookupvalue, lookuprange, 0)
' Go to the applicable row.
sht.Range(8, FirstMatchColumnNumber).Select
End Sub