VBA:Single Loop

tt.viquel

New Member
Joined
Apr 14, 2011
Messages
30
how do i do a single loop that runs through 10 columns A1:A10 to J1:J10 (have queries)and have the results displayed in column L1:L10to U1:U10 so each column and cell have result display in another cell.
 

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.
Hi there,

If you are asking to learn loops, I would think a For Each...Next loop would be easiest, shown in the first. If you are just wanting to get the values from/to equally sized ranges, no need to loop...
Rich (BB code):
Option Explicit
    
' A1:A10 to J1:J10 (have queries)and have the results displayed in column L1:L10to U1:U10 so
'each column and cell have result display in another cell.
Sub exa4()
Dim Cell As Range
    
    For Each Cell In ThisWorkbook.Worksheets("Sheet2").Range("A1:J10")
        Cell.Offset(, 11).Value = Cell.Value
    Next
    
End Sub
    
Sub exa5()
    With ThisWorkbook.Worksheets("Sheet2")
        .Range("L1:U10").Value = .Range("A1:J10").Value
    End With
End Sub
 
Upvote 0
Thank you for your help but can i ask another question. what if i dont want it to be in one loop because these subs separate them into individual ones and i want it to to in one public sub.

and also how come sub 4 and 5 are different 4 specifies one range and 5 specifies 2 ranges
 
Upvote 0
Hi again,

I am afraid I am not following. Can you explain what you mean by 'don't want it in one loop because...'?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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