select every other cell

deb

Active Member
Joined
Feb 1, 2003
Messages
400
How can I select every other cell in Row B, from row 2 thru row 250?

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
What are you trying to do? Noting that it's rarely necessary to select at all.

For example this will add the row # to every other row in that range:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>        <SPAN style="color:#00007F">For</SPAN> i = 2 <SPAN style="color:#00007F">To</SPAN> 250 <SPAN style="color:#00007F">Step</SPAN> 2<br>            Cells(i, "A") = "=ROW()"<br>        <SPAN style="color:#00007F">Next</SPAN> i<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0
This code deleted the cells instead of selecting them.

I need to select them so i can move them to a differnent row.
 
Upvote 0
This code deleted the cells instead of selecting them.

I need to select them so i can move them to a differnent row.

No, that code adds the row # to every other cell in column A. It was just an example of how to work with that range.

If you want the rows moved, where do you want them moved to? And do you want them cut or copied?
 
Upvote 0
Hi

Don't wish to tread on anyones toes here but this is (at least) the second question the OP has started with the guise of selecting every other. Can the OP perhaps clarify exactly what they are doing so they get the answer they need quicker. Some screenshots might be useful

KR


Dave

>>EDIT<<
 
Last edited:
Upvote 0
Thank you for this code but it will not work for me.

I already have data in these cells that i need to move. I want to select every other sell in the column so i can move them. It looks like you code overwrites my data.

How can I just select every other cell in the column?

Thanks again
 
Upvote 0
deb

I posted code for that in the other duplicate thread.:)

But I've got to agree with the others - what are you actually trying to do?
 
Upvote 0
The code in the duplicat thread selects every other row and not every other cell.

The code for every other row works great. but I must be able to select the cell to move it. I cannot move the row.

How can I select every other CELL, without replacing the data or deleting the data?

Data looks like this...

Item1
price1
Item2
price2

I need...

Item1 price1
Item2 price2

so if I can select every other cell in the column, i can move them the correct column.


Thanks,
 
Upvote 0
but I must be able to select the cell to move it

Like I said you rarely need to select:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>        <SPAN style="color:#00007F">For</SPAN> i = 2 <SPAN style="color:#00007F">To</SPAN> 250 <SPAN style="color:#00007F">Step</SPAN> 2<br>            Cells(i, "A").Cut Cells(i, "A").Offset(-1, 1)<br>        <SPAN style="color:#00007F">Next</SPAN> i<br>        <br>        Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

That should do what you want. It moves each price point next to it's Item # in column B, then deletes the now blank rows.

A note for the future is to always test code on a copy of your wb, so you don't lose data. ;)
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,952
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top