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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

BBHRVS

Board Regular
Joined
Nov 3, 2005
Messages
94
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

Titian

Well-known Member
Joined
Dec 17, 2004
Messages
567
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

BBHRVS

Board Regular
Joined
Nov 3, 2005
Messages
94
Sorry, too fast...
second instruction line should be only :
Set cellfin = Celldeb.end (xldown)
 
Upvote 0

Titian

Well-known Member
Joined
Dec 17, 2004
Messages
567
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,195,949
Messages
6,012,481
Members
441,701
Latest member
vnkendijs

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
Top