A snippet of VBA code please

Titian

Well-known Member
Joined
Dec 17, 2004
Messages
567
I have manipulated and sorted my file so that in Column S, the row that I am interested in printing, contains the word "No".

How do I look down column and return the row number of the first row that does not contain "No".

I have attempted to look UP column S however as it contains other things the bottom up count stops at the end of my data set.

Any help is much appreciated.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi Titian;

Try (if your column is well sorted) the "columndifferences" function :

sub titian()
Dim cellfin, celldeb, macell As Range
Set celldeb = ActiveSheet.Cells(1, 19) 'if your data begins at row 1
Set cellfin = ActiveSheet.Celldeb.end (xldown) 'or any other way to find out your last cell...
Set macell = ActiveSheet.Range(celldeb, cellfin).ColumnDifferences(celldeb)(1)
msgbox macell.row
end sub

Should help I guess.
 
Upvote 0
The program falls over at this line

Set cellfin = ActiveSheet.celldeb.End(xlDown)

with the message "Run time error 438", "Object doesn't support this property or method"

Any ideas?
 
Upvote 0
Sorry, too fast...
second instruction line should be only :
Set cellfin = Celldeb.end (xldown)
 
Upvote 0
Thanks a lot, that's OK now.

Just been tweaking my print range to use my new last row and it all hangs together nicely.

Thanks again for your help.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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