Consulting

Results 1 to 4 of 4

Thread: Sleeper: If Row is Selected question

  1. #1
    VBAX Regular MUSASHI's Avatar
    Joined
    Oct 2004
    Location
    Corpus Christi, Texas (Very South)
    Posts
    44

    Sleeper: If Row is Selected question

    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

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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.

  3. #3
    VBAX Regular
    Joined
    Aug 2005
    Posts
    25
    Location
    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
    Last edited by johnske; 08-12-2005 at 03:37 PM. Reason: added VBA tags

  4. #4
    VBAX Newbie erikvangeit's Avatar
    Joined
    Aug 2005
    Location
    Hoeve 31 3272 Testelt
    Posts
    4
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •