Trying to select R1C1 range in VBA for copy/paste

raynman1972

New Member
Joined
Apr 24, 2012
Messages
2
Hello all,

Long time reader, first time poster. I am trying to create a dynamic range using R1C1 that will let me loop through (I have this piece solved for) a number of matrices and copy from one sheet to another- basically, I want to increment the R1C1 values in my loop and step through the ranges.

My challenge is trying to select the R1C1 range so that I can copy it. What is the proper grammar to use here?

Code:
Sub Make_VTO_CSV()

With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .DisplayAlerts = False
End With
    
    Dim a_col, b_col, a_row, b_row As Integer
    Dim CopyRange As Range
    
    a_col = 59
    b_col = 68
    a_row = 5
    b_row = 52
    
    Sheets("VTO_UPLOAD").Select
    Cells.Select
    Selection.ClearContents
    
'Problem starts here  
 
    Sheets("Overstaffing_OUT").Select
    CopyRange = Range(Cells(a_col, a_row).Address, Cells(b_col, b_row).Address).Address

 'Problem ends here
       
    Sheets("VTO_UPLOAD").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
        
With Application
    .ScreenUpdating = True
    .EnableEvents = True
    .DisplayAlerts = True
End With

End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the baord..

Try

Set CopyRange = Range(Cells(a_row, a_col), Cells(b_row, b_col))
CopyRange.Copy
 
Upvote 0

Forum statistics

Threads
1,215,374
Messages
6,124,569
Members
449,173
Latest member
Kon123

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