harveya915
Board Regular
- Joined
- Sep 4, 2015
- Messages
- 141
I have the following code to which I need help adjusting it to fit my needs. I need it for the fill in color to go from C3-G3 but as far down as there is data in column A. The same with the border from C3-G3 but as far down as there is data in column A.
If possible i would like to extend up to C2-G2, however those cells are merged together. Don't know if it would still be possible. IF it is great! if not, not a big deal.
Thanks!
If possible i would like to extend up to C2-G2, however those cells are merged together. Don't know if it would still be possible. IF it is great! if not, not a big deal.
Code:
Private Sub InsertNewWeek_Click()
With Sheets("Sheet1")
.Unprotect Password:="2019"
.Range("C:H").EntireColumn.Insert
.Range("C3:H3") = Array("End Week Total", "Used", "Restocked", "Price Per Item", "Purchase Total", "")
.Range("C4").Formula = "=I4-D4+E4"
.Range("C4", "C" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown
.Range("G4").Formula = "=E4*F4"
.Range("G4", "G" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown
.Range("C:G").columnWidth = 12
.Range("C:G").Interior.Color = RGB(221, 235, 247)
.Range("F:G").NumberFormat = "$#,##0.00"
.Range("C:G").WrapText = True
.Range("C2:G2").MergeCells = True
.Range("C2").Value = Date
.Range("A1").Interior.ColorIndex = 3
.Range("C:G").Borders(xlEdgeLeft).LineStyle = xlContinuous
.Range("C:G").Borders(xlEdgeRight).LineStyle = xlContinuous
.Range("C:G").Borders(xlEdgeBottom).LineStyle = xlContinuous
.Range("C:G").Borders(xlEdgeTop).LineStyle = xlContinuous
.Protect Password:="2019"
End With
Unload UserForm1
End Sub
Thanks!