Help - Column delete, #ref! error

mypantera

New Member
Joined
Feb 22, 2011
Messages
3
Hi everyone,

I have a spreadsheet where the columns are numbered 1 through 14 (cells B4 through O4) then I drop down to cell O6 and that is numbered 15. From there I want to continue counting to B6 which would be 28 and this continues in the back and forth fashion. What I am trying to do is have the ability to delete a column and have the numbering recalculate and keep the numbers in order. I keep getting a #ref! error no matter how I try to do it.

here is what I would like it to look like on my spreadsheet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
28 27 26 25 24 23 22 21 20 19 18 17 16 15
29 30....

then if I delete a column:
1 2 3 4 5 6 7 8 9 10 11 12 13
26 25 24 23 22 21 20 19 18 17 16 15 14
27 28...

Any help is appreciated
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Use the =COLUMN() function.

It's relative to its position in the worksheet which causes problems with some applications, but for what you're doing, it would be great

So Cell B4 would be =COLUMN()+1
 
Last edited:
Upvote 0
I did try the column() function and it worked perfectly for the first row only. Everything after that wouldn't work correctly. Thank you for he suggestion.
 
Upvote 0
Put this in B4 and drag.

=IF(ROW()=4,COLUMN()-1,IF(MOD(ROW(),2)=1,B3-2*(COLUMN()-(COUNT($B$4:$O$4)+1))+1,B3+2*(COLUMN()-2)+1))

It works! No ref errors :D

You may have to expand the range given in the COUNT() function. Contraction (i.e. deletion of columns) is possible without any changes, though.
 
Last edited:
Upvote 0
Vaniificat,
I got it to work using a modified version of your code. THANK YOU! I forgot to mention that there is a space between each row... Here is how I modified it:

Cell(B4) =IF(ROW()=4,COLUMN()-1,IF(MOD(ROW(),2)=1,B3-2*(COLUMN()-(COUNT($B$4:$O$4)+2))+1,B3+2*(COLUMN()-2)+1))

Cell(b6) =IF(ROW()=4,COLUMN()-1,IF(MOD(ROW(),2)=0,B4-2*(COLUMN()-(COUNT($B$4:$N$4)+2))+1,B4+2*(COLUMN()-2)+1))

It repeats the =1 then =0 for every other row. I am not sure why exactly but for the first count() I had to use ($B$4:$O$4) but every other row after that I had to use count($B$4:$N$4)......

Again thank you very much
 
Upvote 0

Forum statistics

Threads
1,224,593
Messages
6,179,791
Members
452,942
Latest member
VijayNewtoExcel

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