Object Required Error - Finding Last Row in Column

SAMCRO2014

Board Regular
Joined
Sep 3, 2015
Messages
160
Hi,

I cannot determine why I am getting the error "Object required" for the following coding for LastRowText:

Set variables
Dim PPDR As Worksheet
Set PPDR = ThisWorkbook.Sheets("PPDR")

Dim SPS As Worksheet
Set SPS = ThisWorkbook.Sheets("SPS+")

Dim Data As Worksheet
Set Data = ThisWorkbook.Sheets("Data")

Dim LastRowText As Long
Set LastRowText = PPDR.Cells(Rows.Count, "P").End(xlUp).Row

I am trying to determine the last row of cells that contain data in column P for worksheet PPDR.
HELP!!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Remove the word Set.
You only "Set" objects, not numbers/strings etc
 
Upvote 0
Rich (BB code):
<del>Set</del> LastRowText = PPDR.Cells(Rows.Count, "P").End(xlUp).Row
 
Upvote 0
Now I am running into another error. I am trying to copy and paste all the cells that contain text in column P to column M and it is not liking me using the LastRowText.

Range("P2:LastRowText").Copy_destination = PPDR.Range("M2")
 
Upvote 0
Try
Code:
Range("P2:P" & LastRowText).Copy PPDR.Range("M2")
 
Upvote 0
Actually it did not work. It selected all of column P and pasted it in Column M. The coding over wrote information in column M when it should not.
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,555
Members
453,053
Latest member
Kiranm13

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