Rayne
asked on
Row count Excel
Hello,
Sub countRows()
ActiveSheet.Range("C3").Se lect
Dim s As Long
'MsgBox ("Rows to end: " & Selection.End(xlDown).Row - (Selection.Row - 1))
s = Selection.End(xlDown).Row - (Selection.Row - 1)
MsgBox "count: " & s
TextBox1.Text = s
End Sub
I am not sure what I am missing….
Sub countRows()
ActiveSheet.Range("C3").Se
Dim s As Long
'MsgBox ("Rows to end: " & Selection.End(xlDown).Row - (Selection.Row - 1))
s = Selection.End(xlDown).Row - (Selection.Row - 1)
MsgBox "count: " & s
TextBox1.Text = s
End Sub
I am not sure what I am missing….
ASKER
.this is giving errors..
This perhaps?
Sub countRows()
Dim s As Long
s = Range("C3").End(xlDown).Row - 2
MsgBox "count: " & s
UserForm1.TextBox1.Text = s
End Sub
I've done it this way
-------------------------- ----------
....
b = Range("C3", Range("C" & Rows.Count).End(xlUp)).Val ue
s = UBound(b, 1)
MsgBox "count: " & s
UserForm1.TextBox1.Text = s
......
--------------------------
....
b = Range("C3", Range("C" & Rows.Count).End(xlUp)).Val
s = UBound(b, 1)
MsgBox "count: " & s
UserForm1.TextBox1.Text = s
......
However, thinking about it, you would probably need to put this code in the userform module.
ASKER
I am still getting a object required error
ASKER
try this
ActiveSheet.TextBox1.Value = s
ActiveSheet.TextBox1.Value
ASKER
Thank you Steve - Awesome that works but there is one issue – can you get it to refresh as I delete or add more row. For example if user adds new rows or delete row, the text box value display refreshes automatically?? Is that achievable? So in essence no need for the test button…
ASKER
I increased the points because I really need to make this module work nice :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect as it can get. Thank you Steve, that is a life saver :)
ASKER
Perfect
ASKER