PDA

View Full Version : Multiple rows slection for operation with rows



rabarber
10-18-2008, 04:19 AM
Hello

I want to select multiple cells and then make oprations with each of the rows cells in my selection.

for one row operations i using this Worksheets("fsd").Cells(Selection.Row, 1) i need to do same operations with multiple selected cells.
maybe some one can tell me how to define cells who is selected
if cells(x,x) is slected then ... in right syntax ?

thank you

GTO
10-18-2008, 04:36 AM
What are you looking to do, based upon the cell "selected"?

rabarber
10-18-2008, 04:59 AM
if i can find cells what are selected, then i could put in in loop and operate with rows.
here is operation what basicly i need to do but i dont now how to define selected cells

Sheet12.Activate

m1: If Sheet12.Cells(x, 2) <> "" Then x = x + 1: GoTo m1

Do While Sheet12.Cells(i, 2) <> ""
If Sheet12.Cells(i, "B") = Selected (dont know right syntax ) Then
Sheet12.Cells(x + 1, "B") = Sheet12.Cells(i, "B")
i = i + 1
Else
i = i + 1
End If
Loop

rabarber
10-21-2008, 05:11 AM
I only want to know how can i define selected celll, If Sheet12.Cells(i, "b") = ActiveCell this dosent fit for me because i have selected more then one cell, and i need to do operations with all of the selected cells.

can anyone help :)

GTO
10-21-2008, 10:20 PM
if i can find cells what are selected, then i could put in in loop and operate with rows.
here is operation what basicly i need to do but i dont now how to define selected cells

Sheet12.Activate

m1: If Sheet12.Cells(x, 2) <> "" Then x = x + 1: GoTo m1

Do While Sheet12.Cells(i, 2) <> ""
If Sheet12.Cells(i, "B") = Selected (dont know right syntax ) Then
Sheet12.Cells(x + 1, "B") = Sheet12.Cells(i, "B")
i = i + 1
Else
i = i + 1
End If
Loop

I'm afraid I'm not following your code very well, but in short, I believe you want to check for each cell in Selection.

Sub j()
Dim rngCell As Range
For Each rngCell In Selection
MsgBox rngCell.Address
Next
End Sub

You may wish to post an example workbook, as the code appears to be both looking at and changing stuff in column B only? And this -> "m1: If Sheet12.Cells(x, 2) <> "" Then x = x + 1: GoTo m1" <- seems to say If a certain cell in column B is not empty, check the next cell in column B. I get that you're trying to find the first empty row, but it just looks like (with everything happening in column B) stuff would be getting overwritten...?