select every other cell

deb

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

Thanks
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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,
 

deb

Active Member
Joined
Feb 1, 2003
Messages
396
This code deleted the cells instead of selecting them.

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

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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?
 

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,002
Office Version
  1. 365
  2. 2016

ADVERTISEMENT

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:

deb

Active Member
Joined
Feb 1, 2003
Messages
396
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
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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?
 

deb

Active Member
Joined
Feb 1, 2003
Messages
396
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,
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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. ;)
 

deb

Active Member
Joined
Feb 1, 2003
Messages
396
wow,

This is exactly what I needed. I did all the work for me.

Thanks!!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,518
Messages
5,596,621
Members
414,082
Latest member
sasmita

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
Top