Find last cell in column and select a cell within a range combination

Status
Not open for further replies.

EngSantiago

New Member
Joined
Mar 19, 2014
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I need some guidance and how to improve VBA code. Currently, I'm using the following command to find a part number "PN" within a range (B2:C5000).
Code:
Worksheets("Data_Base").range("B2:C5000").Find(What:=PN).Select

The problem is that as the parts list gets bigger the formula wont find any PNs after row 5000. The scope is to always adjust the range by finding cell address of the last non-blank cell on column C.

Currently, I'm using the following to get the last cell address on column C.
Code:
lCol = 3lRow = Cells(Rows.Count, 3).End(xlUp).Row
FindLast = ActiveSheet.Cells(lRow, lCol).Address(False, False)

The part I'm having trouble with is getting the below command to select the cell that cointains the "PN" when I use FindLast on the command. I've tried the following but doesnt seem to be working.
Code:
Worksheets("Data_Base").range("B2:Findlast").Find(What:=PN).Select
Code:
Worksheets("Data_Base").range("B2:C2 & FindLast").Find(What:=PN).Select

Please advise.
 

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.
Duplicate https://www.mrexcel.com/forum/excel...umn-select-cell-within-range-combination.html

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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