Error 13 please help

brujo_ds

New Member
Joined
Jul 29, 2010
Messages
10
Sorry if these is not the right place and thanks for helping me.

My problem

I have dimension lastcell as an integer or variant I cannot get these to work.

Dim lastcell As Integer
lastcell = Selection.Rows.Count

ActiveCell.Rows(" 1: & lastcell").EntireRow.Select

Thanks for all the posible help
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Dim lastcell As Long
lastcell = Selection.Rows.Count
Range(ActiveCell, ActiveCell.Offset(lastcell - 1)).EntireRow.Select
 

brujo_ds

New Member
Joined
Jul 29, 2010
Messages
10
I solve it!!! But thanks you have to write it like these. I am sorry about the stupid doubt but I am very noob in vba !!!!


ActiveCell.Rows(" 1:" & lastcell).EntireRow.Select
 

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
I solve it!!! But thanks you have to write it like these. I am sorry about the stupid doubt but I am very noob in vba !!!!


ActiveCell.Rows(" 1:" & lastcell).EntireRow.Select

You don't need the Rows property AND the EntireRow property

Code:
ActiveCell.Rows(" 1:" & lastcell).Select
 

brujo_ds

New Member
Joined
Jul 29, 2010
Messages
10
Thanks another time you are right !!!! I will change it tomorrow morning. The shorter the code is the better and I have that argument a lot of times!! So thanks again.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,207
Messages
5,594,843
Members
413,944
Latest member
3xc3ln00b

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
Top