![Grouping Columns In Excel 2016 Grouping Columns In Excel 2016](/uploads/1/2/4/7/124786801/169880511.png)
For example, if you want to move a column between columns E and F, select column F. Click the Insert command on the Home tab, then select Insert Cut Cells from the drop-down menu. The column will be moved to the selected location, and the columns around it will shift.
![Grouping Columns In Excel 2016 Grouping Columns In Excel 2016](/uploads/1/2/4/7/124786801/196860699.png)
First off, why are you storing the 'city' in a table where it is repeated? It appears to be tied to the car, if so then just store it in the car/city/dates table and use a vlookup if it must be in the other table. This will save on potential mistakes. In answer to your question, here is how I've set up a sheet to test this, you will have to adapt the below code to suit your data layout: Firstly, format all cells in the table as green/available.
This macro will then change all the booked cells. Sub bookings ' This finds the number of rows in the top table (-1 for heading row) Dim numCars As Integer numCars = ActiveSheet.Range('A1').End(xlDown) - 1 ' Tracks the active car row Dim carRow As Integer ' Cells for first row/colum cells in tables Dim dateCell As Range Dim bookingCell As Range ' cycle through the bookings table (bottom) For Each bookingCell In ActiveSheet.Range('A10:' & ActiveSheet.Range('A10').End(xlDown).Address) ' Find which row in top table belongs to this booking's car. Could cause error if doesn't exist! CarRow = ActiveSheet.Columns(1).Find(what:=bookingCell.Offset(0, 1).Value, lookat:=xlWhole, LookIn:=xlValues).Row ' Cycle through dates in top table for comparison For Each dateCell In Range('C1:' & ActiveSheet.Range('C1').End(xlToRight).Address) ' Comparison like this will only work on dates stored properly (not as text) ' If this isn't working, convert your dates by multipling them by 1. ' This can be done in a neighbouring cell like =A1.1, then copying values ' See this link for details: ' ' If the date lies between the booking dates. If dateCell.Value = bookingCell.Offset(0, 2).Value And dateCell.Value.