Hello,
I have a report I generate daily to check past work which I have been manually formatting for a few months -- the last thing I do when formatting is use a double click macro so I can double click a cell and it will change the cell color so I know I have already looked at that line. Well I finally put all the formatting into a macro, however I can't seem to add the double click portion of it. Here is the macro I created:
And here is what I would like to add to it:
I know I can't start a new sub within a sub so I remove those but I still can't seem to get this to run. Any way I have tried to rewrite it with my limited vba knowledge, I either get a compile error or a syntax error. Help is appreciated
*Edit
This part of the code is just a max range I think I would need to fill all the data, but the range I really need is just cells with data in them. So it could be 50 rows or 132 rows, I just don't know how to put that into code, if someone would like to help with that as well, it would be an added bonus.
I have a report I generate daily to check past work which I have been manually formatting for a few months -- the last thing I do when formatting is use a double click macro so I can double click a cell and it will change the cell color so I know I have already looked at that line. Well I finally put all the formatting into a macro, however I can't seem to add the double click portion of it. Here is the macro I created:
Code:
Sub EC_FreightLog()
'
' EC_FreightLog Macro
' Formats the freight log
'
With ActiveSheet
.AutoFilterMode = False
With Range("G1", Range("G" & Rows.Count).End(xlUp))
.AutoFilter 1, "*TK*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
Cells.Select
ActiveWorkbook.Worksheets("rep01034866").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("rep01034866").Sort.SortFields.Add Key:=Range( _
"A2:A105"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("rep01034866").Sort
.SetRange Range("A1:R105")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Columns("K:M").Select
Selection.Delete Shift:=xlToLeft
Columns("N:N").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(9), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.AutoFilter
ActiveSheet.Range("$A$1:$M$200").AutoFilter Field:=3, Criteria1:="="
Range("I4:I139").Select
Range("I139").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.AutoFilter
Columns("A:M").Select
Columns("A:M").EntireColumn.AutoFit
End Sub
And here is what I would like to add to it:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Target.Interior.ColorIndex = 3
End Sub
I know I can't start a new sub within a sub so I remove those but I still can't seem to get this to run. Any way I have tried to rewrite it with my limited vba knowledge, I either get a compile error or a syntax error. Help is appreciated
*Edit
This part of the code is just a max range I think I would need to fill all the data, but the range I really need is just cells with data in them. So it could be 50 rows or 132 rows, I just don't know how to put that into code, if someone would like to help with that as well, it would be an added bonus.
Code:
ActiveSheet.Range("$A$1:$M$200").AutoFilter Field:=3, Criteria1:="="
Range("I4:I139").Select
Range("I139").Activate
Last edited: