Consulting

Results 1 to 3 of 3

Thread: Action to cells in a specific column of selected rows

  1. #1
    VBAX Contributor D_Marcel's Avatar
    Joined
    Feb 2012
    Location
    São Paulo, Brazil
    Posts
    115
    Location

    Action to cells in a specific column of selected rows

    Greetings!
    This one probably can be very simple to some of you, but I'm needing some direction. I'm trying to automatize a very very manual routine, with dozens of steps.

    I want to code the logic based on the selected rows by the user. For example, when the user select the rows 1 and 3:

    A B C D E
    21200 Company A 20.07.2014 100,00 Completed
    21201 Company B 20.07.2014 200,00 Error
    21202 Company C 21.07.2014 300,00 Pending








    I need to perform some actions based on the content of the column "E" to each row selected.
    I thought about...

    "For Each", but with this command, all the cells in the selected rows would be considered.
    "For Variable = 1 to X". Perhaps is better using the "Selection.Rows.Count" as value for "X", but how to reference at the same time, the addresses of the rows and/or cells that's being processed?

    Thanks for reading!

    Sincerely,

    Douglas Marcel
    "The only good is knowledge and the only evil is ignorance". Socrates

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,776
    Something like this might work.

    Dim oneCell as Range
    Dim testString as String
    
    For Each oneCell Application.Intersect(Selection.EntireRow, Range("E1").EntireColumn).Cells
    
        Rem do something
    
        testString = teststring & "," & oneCell.Text
    next oneCell
    
    MsgBox Mid(testString, 2)

  3. #3
    VBAX Contributor D_Marcel's Avatar
    Joined
    Feb 2012
    Location
    São Paulo, Brazil
    Posts
    115
    Location
    It works for me!

    This is the essential, after the [VBA]For Each[/VBA] I'll code the rest.

    Thanks a lot mikerickson!
    "The only good is knowledge and the only evil is ignorance". Socrates

Posting Permissions

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