Question: I'm generating unique keys for invoice by using the below code and im getting **Run time Error 1004 Application defined or object defined error** in line 

```
cell.Value = CStr(d & Mx) 

```

Why I'm getting it?

```
Private Sub Key_Gen()

Dim WIP_rng As Range
Dim d As String, c As Long, r As Long, s As Integer, p As Integer

Set WIP_rng = Range("WIP[Key]")

Mx = WorksheetFunction.Max(keynum)
c = 1
p = 0
    For Each col In WIP_rng
    r = col.Row
        If col.Value = "" And Cells(r, 3).Value <> "" And Cells(r, 4).Value <> "" And Cells(r, 5).Value <> "" And Cells(r, 6).Value <> "" And Cells(r, 7).Value <> "" Then
            s = Val(Len(Trim(Mx)))
            Debug.Print s
            t = 5
            p = t - s
            Debug.Print p
               If p = 1 Then
               p = "0"
               ElseIf p = 2 Then
                p = "00"
               ElseIf p = 3 Then
                p = "000"
               ElseIf p = 4 Then
                p = "0000"
                ElseIf p = 0 Then
                p = ""
               End If
                Mx = CStr(Mx + c)
                d = CStr("MG" & p)
                d = d & Mx
                col.Value = d
        c = c + 1
        End If
    Next

Application.ScreenUpdating = True

End Sub

```

Answer: 
The problem is with the `map` function not the `Pool` object. For this case, `starmap` would be a good choice like this:

```
p.starmap(f, zip([1,2,3], [4,5,6]))

```

From python 3.3 [`starmap`](https://docs.python.org/dev/library/multiprocessing.html#multiprocessing.pool.Pool.starmap) was added to the `Pool` object
I don't really understand how you want to order your parameters but the idea is to have a list of tuples because your function takes 2 arguments, so something like this :

```
p.map(f, [(1, 4), (2, 5), (3, 6)])

```

and make f take a tuple as argument

```
def f(t):
    return t[0] * t[1]

```