Hello, First I apologize for asking a question that I KNOW has been asked before, I can't find it. All I need is a way to count how many cells are between two different cells that the user selects.I have all the selection,and userform programing done but this worksheetfunction.countif is not working for me, and it would be alot easier than some whole looping program just to add up how many cells there are between them.
here is what i have so far
I get the "Topaddress" and "Bottomaddress" values withCode:numberoflables = WorksheetFunction.CountIF(Topaddress & ":" & Bottomaddress, "?*")
Sorry if I sound frustrated, I am...Code:Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Label_Generater.TextBox1.ControlSource = ActiveWindow.ActiveCell.Address Topaddress = Label_Generater.TextBox1.ControlSource End Sub
Thank you very much for your time,
Last edited by TheNewGuy; 03-12-2010 at 09:07 AM.
Just use COUNT.
Do you mean simply change CountIF to Count?
Because I tried that and it gives me 0...Code:numberoflables = WorksheetFunction.Count(Topaddress & ":" & Bottomaddress, "?*")
Thanks
My mistake. COUNT doesn't do what I thought it did. You could try adding blanks and non-blanks (COUNTA + COUNTBLANK)?
I Figured it out, I had to create a custom Range. Like this
This seems to work the way I need it to. I knew I was forgetting something easy Thanks for all your help.Code:Dim MyRNG As Range Set MyRNG = Sheets("CONFIG").Range(Topaddress & ":" & Bottomaddress) numberoflables = WorksheetFunction.CountIf(MyRNG, "?*")
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks