Copy non continuous data to a continuous range -VBA

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. 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?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Oh I just saw that

My keyboard auto correct that

Its G36:G45

10 cells each
 
Upvote 0
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
 
Upvote 0
Code:
Range("G36:G45").Value = Range("A22:A49").Value

or this :
Code:
Range("G36:G45").Formula = Range("A22:A49").Formula
 
Last edited:
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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