Move formula range

Jayling01

New Member
Joined
Feb 10, 2019
Messages
3
Good day all,

I have a SS project to book rooms. Rooms are allocated by rows and dates by columns. I have a VB which counts available or booked rooms by the cell colours. I would like to run the count color formula by the date entered in the first cell in each column, thus being able to jump from date to date and find how many rooms are available on a given date. Any pointers would be much appreciated.

Kind regards,

JJ
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Maybe it would help if you provided the code and a bit more info on how the worksheet is laid out ??
 
Upvote 0
Thank you Michael for your swift reply. The SS is laid out as rows as room numbers and columns as dates. I would like to use the color count to sum rooms occupied or not (yellow is occupied, white is vacant). This works fine. Function CountColor(Rng As Range, RngColor As Range) As Integer
Dim Cll As Range
Dim Clr As Long
Clr = RngColor.Range("A1").Interior.Color
For Each Cll In Rng
If Cll.Interior.Color = Clr Then
CountColor = CountColor + 1
End If
Next Cll
End Function

I want to now select a colum by its date entry (column title) rather than adjusting the range in the formula.
Hope this makes sense.

Thanks again,
JJ
 
Upvote 0
A different approach might be not to have a formula at all
This will work on the whole column, by using the selected cell at the top.
You can either assign it to a button or run the code by Pressing ALT + F8 and selecting the macro
It assumes the "yellow" is standard VBYellow

Code:
Sub MM1()
Dim cell As range, color As Long
color = ActiveCell.Interior.color
For Each cell In range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp))
    If cell.Interior.color = vbYellow Then
        C = C + 1
    End If
Next cell
MsgBox "There are " & C & " rooms booked"
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,376
Messages
6,130,255
Members
449,568
Latest member
mwl_y

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