Forum Discussion

Moath_00's avatar
Moath_00
Copper Contributor
Aug 08, 2022

fill 50k cells automatically

Hi ,

 

I have a work sheet that have 10 k subjects and I should to bring 5 specific info for each subject ( I well bring it from the web ) 

 

So its impossible to fill it by my self

 

Is there any idea for automatically way ??

2 Replies

  • Moath_00 

    Sub expand()
    
    Dim var As Variant
    Dim i As Long
    Dim k As Long
    Dim j As Long
    Dim start As String
    
    Range("D:E").Clear
    
    k = 1
    
    Set var = Range("A1:A10000")
    
    ReDim var(1 To 50000, 1 To 2)
    
    For i = 1 To 10000
    For j = 1 To 5
    
    var(k, 1) = Cells(i, 1).Value
    var(k, 2) = Cells(j, 2).Value
    k = k + 1
    
    Next j
    Next i
    
    Range("D1:E50000").Value = var
    
    End Sub

    Maybe with this code. The subjects are in range A1:A10000 and the specific info is in range B1:B5. In the attached file you can click the button in cell H2 to run the macro.

Resources