Home Copy one range data into two ranges equally using loop code
Reply: 1

Copy one range data into two ranges equally using loop code

Abhishek Singh
1#
Abhishek Singh Published in 2018-01-12 13:17:51Z

I want to copy one range data (l.e., from A2:A20) into two ranges equally (i.e., from B2:C25). If the range one data finish, copy data from the beginning of the range(i.e., from A2).

Vba
MarcinSzaleniec
2#
MarcinSzaleniec Reply to 2018-01-12 13:51:07Z

I am not sure if I get the problem, but macro below copy values form A2:A20 into B2:B25 as many times as needed.

Sub myMacro()
Dim cl As Range, rngTarget As Range, rngSource As Range, clm As Range
Dim iCnt As Integer

Set rngTarget = Range("b2:c25")
Set rngSource = Range("a2:a20")

iCnt = 0
For Each clm In rngTarget.Columns
    For Each cl In clm.Cells
        Debug.Print rngSource.Range("A1").Offset(iCnt Mod rngSource.Cells.Count)
        iCnt = iCnt + 1
    Next cl
Next clm

End Sub
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306012 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO