EngSantiago
New Member
- Joined
- Mar 19, 2014
- Messages
- 17
- Office Version
- 365
- Platform
- 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).
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.
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.
Please advise.
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.