VBA "activecell.range" help

dukeofscouts

Board Regular
Joined
Jan 19, 2009
Messages
146
Hello,

Id like to use a macro to copy a range of cells and paste them in a new range. To do this I've been able to get a macro that reads as follows:

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 5/31/2009 by Dukeofscouts
'
'
Range("A2").Select
ActiveCell.Range("A1:A6").Select
Selection.Copy
ActiveCell.Offset(Range("d1"), Range("f1")).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveCell.Offset(-3, -3).Range("A1").Select
End Sub

Where I need help is getting the "activecell.Range(A1:A6").select to be looking at B1 to read the number of rows in the range. B1 is "=sumproduct(--((a2:a102)<>""))

All my attempts to get this to work have resulted in error messages. Is this possible to do?

Thanks,
D.O.S.
 
Can you step away from the macro and explain in terms of the data the logic steps you're wishing would occur?

Use Excel Jeanie to post up some visible examples of the data you're referring to, and perhaps a mockup of the desired results you have in mind.
 
Upvote 0
Would this work?

Code:
Range("A1:A6").Copy
    Range("B1").PasteSpecial XlPasteType:=xlPasteValues, _
                             XlPasteSpecialOperation:=xlPasteSpecialOperationNone, _
                             SkipBlanks:=False, Transpose:=False

Change B1 to where you want to paste.

Or have I misunderstood your requirements?

John
 
Upvote 0
Are you saying that if the value in cell B1 was 10, then you would want the range to be:

Rich (BB code):
Range("A2:A10").Select
And it if it were 20, then:
Rich (BB code):
Range("A2:A20").Select

If so, you could try:

Rich (BB code):
Range("A2:A" & Range("B1").Value).Select
 
Upvote 0
You got it with that last one! there was my problem I was trying to put the Range ("b1") inside the quotes.

Thanks a million,
D.O.S.
 
Upvote 0

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