Do Loop, Please help!

dhlesg

New Member
Joined
Jul 31, 2011
Messages
14
Hello,
I try to layout a Matrix

A1 A2 A3 A4
A1 1
A2 1
A3 1
A4 1

The code is
___________________________________
Dim numberofcriteria As Integer
Dim Col As Long
numberofcriteria = Range("c7").Value
For i = 1 To numberofcriteria
For Col = 10 To 10 + numberofcriteria - 1
Range("I" & 7 + i).Value = Range("b" & 9 + i).Value
Cells(7, Col).Value = Range("b" & 9 + i).Value
Next Col
'Range("I" & 7 + i).Value = Range("b" & 9 + i).Value
Next i
____________________________________
Somehow my Loop does not work and I can only obtain
A4 A4 A4 A4
A1
A2
A3
A4

Please help .
Thank you in advance
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If I understand your requirements you only need 1 for loop.

Try:
Code:
Sub foo()
    Dim numberofcriteria As Integer
    Dim i As Integer
    
    numberofcriteria = Range("C7").Value
    
    For i = 1 To numberofcriteria
        'Row Output
        Cells(7 + i, 9).Value = Cells(9 + i, 2).Value
        'Column Output
        Cells(7, 9 + i).Value = Cells(9 + i, 2).Value
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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