PDA

View Full Version : Sleeper: If Row is Selected question



MUSASHI
11-01-2004, 08:25 PM
I have 2 userforms, 1 is to enter employee info at hire. 1 is to view employee data. In Userform2 there is a list box which contains the employees from a defined range "Name".

both forms open from a button on the worksheet. How can I force the userform to open based on row...that is currently active...?

Hope that makes sense. If I had 300 records, and I was currently in row 57, and execute the userform, how can I make it open on employee 57?

Thanks
Musashi

Jacob Hilderbrand
11-01-2004, 08:34 PM
You can get the row like this:


Dim x As Long
x = ActiveCell.Row

Then use x in your code that pulls the data for the User Form.

Innany
08-12-2005, 09:12 AM
I am new to VBA and trying to write a code to hide all the rows in a sheet starting from first time it finds 0 in a column until row 1800. I got the code identifying the row number, where the first 0 appears, but get a type mismatch, when trying to use it.
Any help?


Sub HideRowsold()
Dim Row As Long
Sheets("Source_Data").Select
ActiveCell(2, 1).Select
Do While ActiveCell.Value <> 0
ActiveCell.Offset(1, 0).Select
Loop
RowN = ActiveCell.Row
Rows("RowN:1800").Select (this is where I get type mismatch)
Selection.EntireRow.Hidden = True
End Sub

erikvangeit
08-12-2005, 10:27 AM
Hello, Innany,

The right syntax (which you can find using the macro recorder) is:


Rows("1:1800").Select
OR

r1 = 1
r2 = 1800
Rows(r1 & ":" & r2).Select

in your case

RowN = ActiveCell.Row
Rows(RowN & ":1800").Select

getting further with this ?

kind regards,
Erik