PDA

View Full Version : Action to cells in a specific column of selected rows



D_Marcel
07-24-2014, 07:12 PM
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

mikerickson
07-24-2014, 10:01 PM
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)

D_Marcel
07-25-2014, 09:14 AM
It works for me!

This is the essential, after the For Each I'll code the rest.

Thanks a lot mikerickson!