Select lines by their number

Solved
simco -  
simco Posted messages 53 Status Member -
Hello everyone,

I would like to know how it is possible to select multiple non-consecutive rows by their number. Let's imagine I want to select rows 2, 6, 8, and 11 without having to click on their number on the left.
To be clearer, I need to select a series of rows across different Excel sheets, but given the number of rows to select, it would be very laborious to select them one by one while holding down Ctrl.
I hope I have been clear, and I look forward to your responses.

Thank you in advance

Configuration: Windows / Firefox 49.0

3 answers

  1. ccm81 Posted messages 11033 Status Member 2 434
     
    Hello

    We will need to go through a small macro
    http://www.cjoint.com/c/FKgtLaTssvn

    Best regards
    1
    1. simco Posted messages 53 Status Member
       
      Thank you very much for this quick response. It's exactly what I needed :)
      0
    2. simco Posted messages 53 Status Member
       
      I have a problem. The macro works very well in the sheet you provided me. However, when I try it on my sheet, an error message 400 with a white cross on a red background appears. Since I am not at all familiar with VBA, I don't know what to do.
      Thank you for your help.
      0
  2. ccm81 Posted messages 11033 Status Member 2 434
     
    Vous avez bien séparé les numéros de lignes par un espace ?
    0
    1. simco Posted messages 53 Status Member
       
      Yes. While searching, I managed to find something decent.
      On VBA, I went to my sheet and then right-clicked to copy and paste your original code, then I executed it on my sheet from VBA.
      I get an error message saying:

      Runtime Error '13' Type mismatch.

      But when I return to my Excel sheet, the desired rows are selected. I don't know why I'm getting this error message. So basically, I think I can do it this way. It won't be as quick as just Ctrl + K, but it's better than nothing :)

      Maybe it's because my Excel workbook is saved as .xlxs?
      0
  3. ccm81 Posted messages 11033 Status Member 2 434
     
    You need to save it in xlsm format

    A version to clean the list
    Public Sub OK()
    Dim s, ts, k, plage As Range
    s = Selection.Value
    s = Trim(s)
    While InStr(1, s, " ")
    s = Replace(s, " ", " ")
    Wend
    ts = Split(s, " ")
    Set plage = Rows(ts(0))
    For k = 1 To UBound(ts)
    Set plage = Union(plage, Rows(ts(k)))
    Next k
    plage.Select
    End Sub
    Cdlmnt
    0
    1. simco Posted messages 53 Status Member
       
      Tip top. Everything is going wonderfully. Thank you very much :)
      0