help with code error

dantheman9

Board Regular
Joined
Feb 5, 2011
Messages
175
Hi i have the following code (below);

Code:
x = 2
Set Rrange = Range(Cells(3, x), Cells(3, x + (k - 1)))
b = numbers
Do Until b = 0
Rrange.Copy
Sheets("TEMPS1").Activate
Range("B65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll
' testering
Sheets("TEMPS").Activate
[COLOR=red]Cells(1, k).End(xlRight).Select
[/COLOR]vf = ActiveCell.Column
x = x + k
k = vf
 
Sheets("TEMPS").Activate
Set Rrange = Range(Cells(3, x), Cells(3, x + (k - 1)))
b = b - 1
Loop

I think the cell selection is the issue, but don't know how else to select it?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi,

I doubt its really nescessary to actually select the cell for what your trying to do, try working with the cell without selecting it ;)

As for your problem:

Change:

Code:
End(xlRight)

For

Code:
End(xlToRight)
 
Upvote 0
As an FYI
Code:
Range("B65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll
Can be changed to:
Code:
Range("B" & Rows.Count).End(xlUp).Offset(1,0).Paste
Rows.Count saves having to remember the last row number and if you're pasting everything then no real need to use PasteSpecial, infact, I think you could reduce the code to:
Code:
Rrange.Copy Destination:=Sheets("TEMPS1").Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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