copy a variable range

methode2404

New Member
Joined
Sep 3, 2018
Messages
30
Hi,

i have to copy a variable range in a for next loop,
"s" is a variable

the line in bold doesn't work
it should copy the range from activecell to row "s" (s is a integer)

Sheets("taslak").Activate
ActiveCell.Offset(0, 1).Select
Range(Cells(0, 0), Cells(0 & s)).Select
Selection.Copy

Who can help me

Best regards
Metin
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
There is no such thing as a Cells with 0 rows or 0 columns.
You probably want
Code:
Range (Cells(ActiveCell
.Row,ActiveCell.Column),Cells(ActiveCell.Row,s))
 
Last edited:
Upvote 0
S = 25 is for illustration only

Code:
Sub SelectRange()
    Dim cel As Range, s As Long
    s = 25
    Set cel = ActiveCell
    Range(cel, Cells([COLOR=#ff0000]s[/COLOR], cel.Column)).Select
End Sub

There is no requirement to select a range to copy it
Code:
Sub SelectRange()
    Dim cel As Range, s As Long
    s = 25
    Set cel = ActiveCell
    Range(cel, Cells([COLOR=#ff0000]s[/COLOR], cel.Column)).Copy
End Sub
 
Upvote 0
I know it's wrong (it doesn't work)
can you say how it's work ?
it should copy the range from activecell to row "s" (s is a integer)

for example : activecell is c7
and s=12

it should select the range C7:C12

select activecell:same_column,row 12
 
Upvote 0
Eek, and apologies for my bad on putting the s as the column. Teach me to post code on my phone :(
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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