Copy non continuous data to a continuous range -VBA

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
1,751
Office Version
2016
Platform
Windows
I want to set the value for G36:G54 to data from cells

A22
A25
A28
A31
A34
A37
A40
A43
A46
A49

I cannot seem to get the coolest way to get it done.

Can someone pull it out for me?
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
1,751
Office Version
2016
Platform
Windows
Oh I just saw that

My keyboard auto correct that

Its G36:G45

10 cells each
 

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
I want to set the value for G36:G54 to data from cells

A22
A25
A28
A31
A34
A37
A40
A43
A46
A49

I cannot seem to get the coolest way to get it done.

Can someone pull it out for me?


Maybe this?

Code:
Sub Test()
    iStart = 22
    For Each xlCell In Sheets("Sheet1").Range("G36:G45")
        xlCell.Value = Sheets("Sheet1").Range("A" & iStart).Value
        iStart = iStart + 3
    Next xlCell
End Sub
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,846
Office Version
2016
Platform
Windows
Code:
Range("G36:G45").Value = Range("A22:A49").Value
or this :
Code:
Range("G36:G45").Formula = Range("A22:A49").Formula
 
Last edited:

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,762
Office Version
2013
Platform
Windows
Try this:
Code:
Sub Fill_Range()
'Modified 7/22/2019 10:33:17 AM  EDT
Dim i As Long
Dim x As Long
x = 22
For i = 36 To 45
    Cells(i, "G").Value = Cells(x, 1).Value
    x = x + 3
Next
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,846
Office Version
2016
Platform
Windows
Sorry, I didn't pay attention to "non continuous" !
 

Watch MrExcel Video

Forum statistics

Threads
1,102,439
Messages
5,486,900
Members
407,570
Latest member
cannotquitexcel

This Week's Hot Topics

Top