VBA question regarding changing column border

randomString

New Member
Joined
Oct 4, 2011
Messages
1
Hi,

I am currently creating a spreadsheet on Excel 2003 and need to conditionally format some data. I have already used all 3 conditions for this particular range so am trying to use VBA to do my final formatting.

Essentially I have some data organized into columns by week (date format). I want to change the border of that column to red if the look-up date falls within that week. The column's date is in row 5 of the current column and is the first day of that week.

I don't know much VBA so I have cobbled together something that probably has large errors in it.

Thanks for any help you can all offer!

---


Here is what I have (put together piecemeal from various sources):


Private Sub Workbook_Open()

Set DataRange = Range("k6:bf66")
For Each Col In DataRange

Dim columnDate As Date
Dim todaysDate As Date
Dim nextWeeksDate As Date

columnDate = Range(Col.Column & "5").Value
todaysDate = Range(f1).Value
nextWeeksDate = todaysDate + 7

If todaysDate >= columnDate And todaysDate < nextWeeksDate Then

Range(lookUpCell).Borders(xlEdgeLeft).LineStyle = xlContinuous
Range(lookUpCell).Borders(xlEdgeLeft).Color = vbRed

Range(lookUpCell).Borders(xlEdgeRight).LineStyle = xlContinuous
Range(lookUpCell).Borders(xlEdgeRight).Color = vbRed

End If

Next
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,224,608
Messages
6,179,872
Members
452,949
Latest member
Dupuhini

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