michealj46
08-05-2007, 02:01 AM
ew to VBA this is my first project.
I am building a calendar to track bookings.
The months are laid out in blocks ( 6 down , 2 across) of 5 rows by 7 columns.
Booking dates are highlighted by selecting with the mouse and clicking a button to set the cell fill colour.
Ideally I want to identify the first and last cells of the selection by using a different colour fill than that of the rest of the selection.
The sub I have for filling isas follows
Dim r As Range, last As Range
Set r = Selection
With r.Interior
.ColorIndex = 4
.Pattern = xlSolid
.PatternColorIndex = 1
End With
Set last = r.Cells.Item(r.Cells.Rows.Count, r.Cells.Columns.Count)
last.Interior.ColorIndex = 1
This highlights the last cell for a complete row or rows
The problem is when I have one full row and a partial second row .
The different colour ends up on end column of the last complete row.
I would apprceciate help with this and a suggestion of how to select the first cell
Thanks
Micheal
I am building a calendar to track bookings.
The months are laid out in blocks ( 6 down , 2 across) of 5 rows by 7 columns.
Booking dates are highlighted by selecting with the mouse and clicking a button to set the cell fill colour.
Ideally I want to identify the first and last cells of the selection by using a different colour fill than that of the rest of the selection.
The sub I have for filling isas follows
Dim r As Range, last As Range
Set r = Selection
With r.Interior
.ColorIndex = 4
.Pattern = xlSolid
.PatternColorIndex = 1
End With
Set last = r.Cells.Item(r.Cells.Rows.Count, r.Cells.Columns.Count)
last.Interior.ColorIndex = 1
This highlights the last cell for a complete row or rows
The problem is when I have one full row and a partial second row .
The different colour ends up on end column of the last complete row.
I would apprceciate help with this and a suggestion of how to select the first cell
Thanks
Micheal