Badge Report Macro

julievandermeulen

Board Regular
Joined
Jan 25, 2020
Messages
91
Office Version
  1. 365
Platform
  1. Windows
I need help creating a macro to format a report I have to run every week at work. It takes 2 hours to format it. I have tried to download the XL2BB but it won't download. Is there another way to share a workbook?
 
Ok I let it run for the last 30 minutes but this has been on the screen the whole time
1736130468971.png
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Actually it finishes in such time, but it will take time to finish copy/paste process.
30 min is too much.

My little pc runs and finishes in 25 sec in total as I mentioned while the msgbox at the end saying 9.00212...
 
Upvote 0
I tried again and got the message box
1736134287262.png
but nothing changes on the MasterTab sheet. I waited 45 minutes. :(

Thank you so much for trying to help me.

What other information could I give you to maybe make it easier and quicker?
 
Upvote 0
The output will be in "Master Tab Complete" sheet, not on "Master Tab".
If you want it to happen on the same sheet, you can replace the data with the result in "Master Tab Complete".
 
Upvote 0
I've been monitoring the thread. Tried running the code in the workbook and it errored out. Never did run. ???
 
Upvote 0

julievandermeulen​

If you want it to happen in the same sheet, try the attached.

 
Upvote 0
Great ! Thanks. Your file works well.
 
Upvote 0
I'm sorry. I should have been more clear.

the MasterTab sheet is the report I run. Then I format it to look like the MasterTab Complete Sheet, but it is all done on the MasterTab sheet. It takes about 1 - 1 1/2 hours to format its.

I would like to run a macro on the MasterTab sheet.

I tried your attached file but my computer won't open it.
 
Upvote 0
Did you unlock the file?
Before you open
Right-click the file, select Properties, and then check the Unblock box on the General tab.

The code I posted was to update the Master Tab Complete sheet.

This will output in Master Tab sheet used in attached workbook.
Code:
Sub test()
    Dim myAreas As Areas, r As Range, c As Range, s$, sp As Shape, HD()
    Dim a, i&, ws As Worksheet, myNames, dic As Object, xx As Single
    xx = Timer
    Set dic = CreateObject("Scripting.Dictionary")
    Set ws = Sheets.Add
    ws.UsedRange.Clear
    For Each sp In ws.Shapes
        sp.Delete
    Next
    Set myAreas = Sheets("master tab").Rows(3).SpecialCells(2).Areas
    ReDim myNames(1 To myAreas.Parent.Parent.UsedRange.Count), HD(1 To 2)
    HD(1) = myAreas(1).Cells(1): HD(2) = myAreas(1).Cells(2)
    For Each r In myAreas
        Set c = r.CurrentRegion
        a = c.Value
        For i = 3 To UBound(a, 2)
            ReDim Preserve HD(1 To UBound(HD) + 1): HD(UBound(HD)) = a(1, i)
        Next
        For i = 2 To UBound(a, 1)
            If a(i, 1) <> "" Then
                s = Join(Array(a(i, 1), a(i, 2)), Chr(2))
                If Not dic.exists(s) Then
                    Set dic(s) = c(i, 1).Resize(c(i, 1).MergeArea.Rows.Count, UBound(a, 2))
                    myNames(dic.Count) = s
                End If
            End If
        Next
    Next
    ReDim Preserve HD(1 To UBound(HD) + 1): HD(UBound(HD)) = "Notes"
    ReDim Preserve myNames(1 To dic.Count)
    mySort myNames, 1, UBound(myNames)
    GetAllData myAreas, HD, myNames, dic, ws, 4
    MsgBox Timer - xx
End Sub

Sub GetAllData(myAreas As Areas, HD, myNames, dic As Object, ws As Worksheet, x&)
    Dim a, i&, ii&, t&, s$, c As Range, n&, ff$
    Application.ScreenUpdating = False
    n = x
    For i = 1 To UBound(myNames)
        s = myNames(i)
        dic(s).Copy ws.Cells(n, 3)
        Set dic(s) = ws.Cells(n, 3)
        n = n + dic(s).Cells(1).MergeArea.Rows.Count
    Next
    For i = 2 To myAreas.Count
        Set c = myAreas(i).CurrentRegion
        a = c.Value: t = t + myAreas(i - 1).CurrentRegion.Columns.Count - 2
        For ii = 2 To UBound(a, 1)
            If a(ii, 1) <> "" Then
                s = Join(Array(a(ii, 1), a(ii, 2)), Chr(2))
                c(ii, 3).Resize(c(ii, 1).MergeArea.Rows.Count, UBound(a, 2) - 2).Copy dic(s).Cells(1, t + 4 - 1)
            End If
        Next
    Next
    ws.UsedRange.Font.Size = 12
    Set c = ws.Cells.Find("not on file", , , 1)
    Application.DisplayAlerts = False
    If Not c Is Nothing Then
        ff = c.Address
        Do
            c.Resize(c.EntireRow.Range("c1").MergeArea.Rows.Count).Merge
            Set c = ws.Cells.FindNext(c)
        Loop While ff <> c.Address
    End If
    Application.DisplayAlerts = True
    With ws.Cells(x - 1, 3).Resize(, UBound(HD))
        .Value = HD
        .HorizontalAlignment = xlCenter
        .Font.Bold = True: .Font.Color = vbWhite
        .Interior.Color = 3484450
        .Borders(11).Weight = 2
        .Borders(11).Color = vbWhite
        .WrapText = True
    End With
    ws.Columns.AutoFit
    ws.Rows.AutoFit
    ws.Cells.Copy Sheets("master tab").[a1]
    Application.DisplayAlerts = False
    ws.Delete
    Application.DisplayAlerts = True
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub

Sub mySort(Ary, LB, UB)
    Dim i As Long, ii As Long, M, temp
    i = UB: ii = LB
    M = Ary(Int((LB + UB) / 2))
    Do While ii <= i
        Do While Ary(ii) < M: ii = ii + 1: Loop
        Do While Ary(i) > M: i = i - 1: Loop
        If ii <= i Then
            temp = Ary(i): Ary(i) = Ary(ii): Ary(ii) = temp
            i = i - 1: ii = ii + 1
        End If
    Loop
    If LB < i Then mySort Ary, LB, i
    If ii < UB Then mySort Ary, ii, UB
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,653
Messages
6,186,205
Members
453,340
Latest member
yearego021

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