VBA colour rows

MiGon

New Member
Joined
Oct 27, 2020
Messages
28
Office Version
  1. 2013
Platform
  1. Windows
Hi Guys,
I search the forum and the internet but could not find the solution, :( I have mulitple rows (number of rows chane each month)
which must be split between staff (number of staff change each month),
I found on the forum piece of code whi sligtly modified (Thank you for the author)

I need to colour rows equally to each person so they can work at the same time on the master file.
Could someone have a look please, I tried to split column A to number of people but this is not want I want to achieve :(

I1 = Number of rows
J1 = Number of staff
K1 = Number of rows for each rounded up

I have no idea how to colour

VBA Code:
Sub count_rows()
  '1. Check how many rows per person
 
 Dim count As Long
    count = ActiveSheet.Range("D2", ActiveSheet.Cells(Rows.count, "D").End(xlUp)).count
  '  MsgBox count
    MyVector = Range("I1").Resize(count).Value
    Range("I1").Value = count
   
    Range("K1").FormulaR1C1 = "=ROUNDUP((RC[-2]/RC[-1]),0)"
   
'  2. Split into cells
   
Dim X As Long, LastRow As Long, vArrIn As Variant, vArrOut As Variant
    Dim Num_rows As Range
    Set Num_rows = Range("K1")
    LastRow = Cells(Rows.count, 1).End(xlUp).row
      
    vArrIn = Range("A1:A" & LastRow)
    ReDim vArrOut(1 To Num_rows, 1 To Int(LastRow / Num_rows) + 1)
    For X = 0 To LastRow - 1
    vArrOut(1 + (X Mod Num_rows), 1 + Int(X / Num_rows)) = vArrIn(X + 1, 1)
    Next
    Range("M2").Resize(Num_rows, UBound(vArrOut, 2)) = vArrOut
    
    Range("M2").Select
   Selection.Delete Shift:=xlUp




End Sub
 

Attachments

  • Capture.PNG
    Capture.PNG
    8.7 KB · Views: 9

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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