Hi All,
I need to add to this code .Interior.ColorIndex where certain conditions within a range apply. I would like to place it within the With statement(Highlighted red).
The code works perfectly otherwise.
Anyone have any ideas.
Many thanks in Advance.
My code:
Dim MACRO As Workbook
Dim Timestamp As Date
Dim Lastrow As Integer
Dim ii As Long
Dim i As Integer
Dim erow As Integer
Dim Month As String
Dim finalRow As Integer
Month = "July"
Timestamp = Now()
Lastrow = ActiveSheet.Range("C" & Rows.Count).End(xlUp).row
For i = 1 To Lastrow
Set MACRO = ActiveWorkbook
row = 2
'Application.ScreenUpdating = False
If Cells(i, 1) = 1 Then
MACRO.Worksheets("Data").Range(Cells(i, 3), Cells(i, 23)).Select
Selection.Copy
Workbooks.Open Filename:="C:\" 'My File Location
Worksheets(Month).Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 1).row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.PasteSpecial
With ActiveSheet.Range("B1:U1").End(xlDown) ' Ctrl+Down
.Offset(1, -1).Range("B1:U1").Select '
.Offset(1, -1).Range("A1:U1").Interior.ColorIndex = 24
.Offset(1, -1).Range("A1:U1").Font.Bold = True
Application.CommandBars.ExecuteMso ("AutoSum")
.Cells.End(xlDown).Range("A") = "Total" ' This part doesn’t work!
ActiveSheet.Cells.End(xlUp).Offset(0, 23) = "as @ " & Now()
.Offset(0, 22).Cells.End(xlUp).Interior.ColorIndex = 28
End With
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub
I need to add to this code .Interior.ColorIndex where certain conditions within a range apply. I would like to place it within the With statement(Highlighted red).
The code works perfectly otherwise.
Anyone have any ideas.
Many thanks in Advance.
My code:
Dim MACRO As Workbook
Dim Timestamp As Date
Dim Lastrow As Integer
Dim ii As Long
Dim i As Integer
Dim erow As Integer
Dim Month As String
Dim finalRow As Integer
Month = "July"
Timestamp = Now()
Lastrow = ActiveSheet.Range("C" & Rows.Count).End(xlUp).row
For i = 1 To Lastrow
Set MACRO = ActiveWorkbook
row = 2
'Application.ScreenUpdating = False
If Cells(i, 1) = 1 Then
MACRO.Worksheets("Data").Range(Cells(i, 3), Cells(i, 23)).Select
Selection.Copy
Workbooks.Open Filename:="C:\" 'My File Location
Worksheets(Month).Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 1).row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.PasteSpecial
With ActiveSheet.Range("B1:U1").End(xlDown) ' Ctrl+Down
.Offset(1, -1).Range("B1:U1").Select '
.Offset(1, -1).Range("A1:U1").Interior.ColorIndex = 24
.Offset(1, -1).Range("A1:U1").Font.Bold = True
Application.CommandBars.ExecuteMso ("AutoSum")
.Cells.End(xlDown).Range("A") = "Total" ' This part doesn’t work!
ActiveSheet.Cells.End(xlUp).Offset(0, 23) = "as @ " & Now()
.Offset(0, 22).Cells.End(xlUp).Interior.ColorIndex = 28
End With
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub