Find last row based on text in a cell

Shadkng

Active Member
Joined
Oct 11, 2018
Messages
365
Hi, can the code below be revised to find the last row up to a cell with a specific word, "FABRIC", in column A? I have a variable section I want to copy but it has blank rows separating portions of it, so the find last row stops at the first blank line. Below is a snapshot of my table.

Thanks

Sub TOT_FAB()

Application.ScreenUpdating = False
Range("A8:C" & Range("A8").End(xlDown).Row).Copy

Sheets.Add(After:=Sheets("PARTS LIST")).name = "TOT FAB"

Worksheets("TOT FAB").Range("A3").PasteSpecial Paste:=xlPasteFormulas

Range("C:C").Select
Selection.TextToColumns Destination:=Range("C3"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="X", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("E3").Select

Columns("A:A").AutoFit
Columns("B:B").HorizontalAlignment = xlCenter
Columns("C:E").HorizontalAlignment = xlLeft
Columns("B:B").ColumnWidth = 5
Columns("C:D").ColumnWidth = 6

Range("A1") = "DESCRIPTION"
Range("B1") = "QUA"
Range("C1") = "WID"
Range("D1") = "LEN"

Application.ScreenUpdating = True

End Sub
VBA Code:

1618069743316.png
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Is there any data in Column A below the word FABRIC?
 
Upvote 0
Try...
VBA Code:
Range("A8:C" & Columns(1).Find("FABRIC", , xlValues, , xlByRows, xlPrevious).Row).Copy
if the word FABRIC only appears once in Column A.
 
Upvote 0
Solution
Try...
VBA Code:
Range("A8:C" & Columns(1).Find("FABRIC", , xlValues, , xlByRows, xlPrevious).Row).Copy
if the word FABRIC only appears once in Column A.
Hi, it worked. I added a "-1" to not include the "fabric" line. It worked as well. Thanks!

Range("A8:C" & Columns(1).Find("FABRIC", , xlValues, , xlByRows, xlPrevious).Row - 1).Copy
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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